diff --git a/modules/hub/src/main/actorApi.scala b/modules/hub/src/main/actorApi.scala index abec430abb..eb92aa9ec5 100644 --- a/modules/hub/src/main/actorApi.scala +++ b/modules/hub/src/main/actorApi.scala @@ -117,5 +117,5 @@ package bookmark { } package relation { - case class ReloadFriends(userId: String) + case class ReloadFollowing(userId: String) } diff --git a/modules/relation/src/main/Env.scala b/modules/relation/src/main/Env.scala index 597396340a..43acab826d 100644 --- a/modules/relation/src/main/Env.scala +++ b/modules/relation/src/main/Env.scala @@ -40,7 +40,7 @@ final class Env( socketHub = hub.socket.hub, getOnlineUserIds = getOnlineUserIds, getUsername = getUsername, - getFriendIds = cached.friends.apply + api = api )), name = ActorName) { diff --git a/modules/relation/src/main/RelationActor.scala b/modules/relation/src/main/RelationActor.scala index da62db445e..85601b28ac 100644 --- a/modules/relation/src/main/RelationActor.scala +++ b/modules/relation/src/main/RelationActor.scala @@ -13,7 +13,7 @@ private[relation] final class RelationActor( socketHub: ActorLazyRef, getOnlineUserIds: () ⇒ Set[String], getUsername: String ⇒ Fu[String], - getFriendIds: String ⇒ Fu[Set[String]]) extends Actor { + api: RelationApi) extends Actor { private type ID = String private type Username = String @@ -21,10 +21,10 @@ private[relation] final class RelationActor( def receive = { - // triggers friends reloading for this user id - case ReloadFriends(userId) ⇒ getFriendIds(userId) flatMap { ids ⇒ + // triggers following reloading for this user id + case ReloadFollowing(userId) ⇒ api.following(userId) flatMap { ids ⇒ ((ids intersect onlineIds).toList map getUsername).sequenceFu - } map { SendTo(userId, "friends", _) } pipeTo socketHub.ref + } map { SendTo(userId, "following_onlines", _) } pipeTo socketHub.ref case NotifyMovement ⇒ { val prevIds = onlineIds @@ -42,17 +42,17 @@ private[relation] final class RelationActor( onlines = onlines -- leaveIds ++ enters - notifyFriends(enters, "friend_enters") - notifyFriends(leaves, "friend_leaves") + notifyFollowers(enters, "following_enters") + notifyFollowers(leaves, "following_leaves") } } private var onlines = Map[ID, Username]() private def onlineIds: Set[ID] = onlines.keySet - private def notifyFriends(users: List[User], message: String) { + private def notifyFollowers(users: List[User], message: String) { users foreach { - case (id, name) ⇒ getFriendIds(id) foreach { ids ⇒ + case (id, name) ⇒ api.followers(id) foreach { ids ⇒ val notify = ids filter onlines.contains if (notify.nonEmpty) socketHub ! SendTos(notify.toSet, message, name) } diff --git a/modules/relation/src/main/RelationApi.scala b/modules/relation/src/main/RelationApi.scala index eaedfcae08..cc3fdf35f1 100644 --- a/modules/relation/src/main/RelationApi.scala +++ b/modules/relation/src/main/RelationApi.scala @@ -3,7 +3,7 @@ package lila.relation import lila.db.api._ import lila.db.Implicits._ import lila.game.GameRepo -import lila.hub.actorApi.relation.ReloadFriends +import lila.hub.actorApi.relation.ReloadFollowing import lila.hub.actorApi.timeline.{ Propagate, Follow ⇒ FollowUser } import lila.hub.ActorLazyRef import lila.user.tube.userTube @@ -65,5 +65,5 @@ final class RelationApi( private def refresh(u1: ID, u2: ID): Funit = cached.invalidate(u1, u2) >>- - List(u1, u2).foreach(actor ! ReloadFriends(_)) + List(u1, u2).foreach(actor ! ReloadFollowing(_)) } diff --git a/modules/socket/src/main/Handler.scala b/modules/socket/src/main/Handler.scala index a61bac7ffc..f209ca2fab 100644 --- a/modules/socket/src/main/Handler.scala +++ b/modules/socket/src/main/Handler.scala @@ -7,7 +7,7 @@ import play.api.libs.json._ import actorApi._ import lila.common.PimpedJson._ -import lila.hub.actorApi.relation.ReloadFriends +import lila.hub.actorApi.relation.ReloadFollowing import makeTimeout.large object Handler { @@ -24,8 +24,8 @@ object Handler { val baseController: Controller = { case ("p", _) ⇒ socket ! Ping(uid) - case ("friends", _) ⇒ userId foreach { u ⇒ - hub.actor.relation ! ReloadFriends(u) + case ("following_onlines", _) ⇒ userId foreach { u ⇒ + hub.actor.relation ! ReloadFollowing(u) } case msg ⇒ logwarn("Unhandled msg: " + msg) } diff --git a/public/javascripts/big.js b/public/javascripts/big.js index 189bac1659..87422a91ef 100644 --- a/public/javascripts/big.js +++ b/public/javascripts/big.js @@ -147,7 +147,7 @@ var lichess_sri = Math.random().toString(36).substring(5); // 8 chars self.syncFriends(); }, self.options.syncFriendsDelay); this.ws.send(JSON.stringify({ - t: "friends" + t: "following_onlines" })); }, handle: function(m) { @@ -227,13 +227,13 @@ var lichess_sri = Math.random().toString(36).substring(5); // 8 chars socket: null, socketDefaults: { events: { - friends: function(data) { + following_onlines: function(data) { $('#friend_box').friends("set", data); }, - friend_enters: function(name) { + following_enters: function(name) { $('#friend_box').friends('enters', name); }, - friend_leaves: function(name) { + following_leaves: function(name) { $('#friend_box').friends('leaves', name); }, n: function(e) { @@ -1274,7 +1274,7 @@ var lichess_sri = Math.random().toString(36).substring(5); // 8 chars this.repaint(); }, enters: function(user) { - this.list.append(renderUser(user)); + this.list.append(_renderUser(user)); this.repaint(); }, leaves: function(user) { diff --git a/todo b/todo index c830dfa5aa..cf7c996020 100644 --- a/todo +++ b/todo @@ -71,6 +71,7 @@ takeback/enpassant glitch http://en.lichess.org/forum/lichess-feedback/i-found-a show teams in user mini badges for top players in ELO and number of games top menu is too long in french with long username +have a forum post redirection instead of assuming the last topic page - applies to search and timelines DEPLOY p21 ----------