show all followers in friend box
This commit is contained in:
parent
892ac89255
commit
d40c014f5a
|
@ -117,5 +117,5 @@ package bookmark {
|
||||||
}
|
}
|
||||||
|
|
||||||
package relation {
|
package relation {
|
||||||
case class ReloadFriends(userId: String)
|
case class ReloadFollowing(userId: String)
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ final class Env(
|
||||||
socketHub = hub.socket.hub,
|
socketHub = hub.socket.hub,
|
||||||
getOnlineUserIds = getOnlineUserIds,
|
getOnlineUserIds = getOnlineUserIds,
|
||||||
getUsername = getUsername,
|
getUsername = getUsername,
|
||||||
getFriendIds = cached.friends.apply
|
api = api
|
||||||
)), name = ActorName)
|
)), name = ActorName)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@ private[relation] final class RelationActor(
|
||||||
socketHub: ActorLazyRef,
|
socketHub: ActorLazyRef,
|
||||||
getOnlineUserIds: () ⇒ Set[String],
|
getOnlineUserIds: () ⇒ Set[String],
|
||||||
getUsername: String ⇒ Fu[String],
|
getUsername: String ⇒ Fu[String],
|
||||||
getFriendIds: String ⇒ Fu[Set[String]]) extends Actor {
|
api: RelationApi) extends Actor {
|
||||||
|
|
||||||
private type ID = String
|
private type ID = String
|
||||||
private type Username = String
|
private type Username = String
|
||||||
|
@ -21,10 +21,10 @@ private[relation] final class RelationActor(
|
||||||
|
|
||||||
def receive = {
|
def receive = {
|
||||||
|
|
||||||
// triggers friends reloading for this user id
|
// triggers following reloading for this user id
|
||||||
case ReloadFriends(userId) ⇒ getFriendIds(userId) flatMap { ids ⇒
|
case ReloadFollowing(userId) ⇒ api.following(userId) flatMap { ids ⇒
|
||||||
((ids intersect onlineIds).toList map getUsername).sequenceFu
|
((ids intersect onlineIds).toList map getUsername).sequenceFu
|
||||||
} map { SendTo(userId, "friends", _) } pipeTo socketHub.ref
|
} map { SendTo(userId, "following_onlines", _) } pipeTo socketHub.ref
|
||||||
|
|
||||||
case NotifyMovement ⇒ {
|
case NotifyMovement ⇒ {
|
||||||
val prevIds = onlineIds
|
val prevIds = onlineIds
|
||||||
|
@ -42,17 +42,17 @@ private[relation] final class RelationActor(
|
||||||
|
|
||||||
onlines = onlines -- leaveIds ++ enters
|
onlines = onlines -- leaveIds ++ enters
|
||||||
|
|
||||||
notifyFriends(enters, "friend_enters")
|
notifyFollowers(enters, "following_enters")
|
||||||
notifyFriends(leaves, "friend_leaves")
|
notifyFollowers(leaves, "following_leaves")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var onlines = Map[ID, Username]()
|
private var onlines = Map[ID, Username]()
|
||||||
private def onlineIds: Set[ID] = onlines.keySet
|
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 {
|
users foreach {
|
||||||
case (id, name) ⇒ getFriendIds(id) foreach { ids ⇒
|
case (id, name) ⇒ api.followers(id) foreach { ids ⇒
|
||||||
val notify = ids filter onlines.contains
|
val notify = ids filter onlines.contains
|
||||||
if (notify.nonEmpty) socketHub ! SendTos(notify.toSet, message, name)
|
if (notify.nonEmpty) socketHub ! SendTos(notify.toSet, message, name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package lila.relation
|
||||||
import lila.db.api._
|
import lila.db.api._
|
||||||
import lila.db.Implicits._
|
import lila.db.Implicits._
|
||||||
import lila.game.GameRepo
|
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.actorApi.timeline.{ Propagate, Follow ⇒ FollowUser }
|
||||||
import lila.hub.ActorLazyRef
|
import lila.hub.ActorLazyRef
|
||||||
import lila.user.tube.userTube
|
import lila.user.tube.userTube
|
||||||
|
@ -65,5 +65,5 @@ final class RelationApi(
|
||||||
|
|
||||||
private def refresh(u1: ID, u2: ID): Funit =
|
private def refresh(u1: ID, u2: ID): Funit =
|
||||||
cached.invalidate(u1, u2) >>-
|
cached.invalidate(u1, u2) >>-
|
||||||
List(u1, u2).foreach(actor ! ReloadFriends(_))
|
List(u1, u2).foreach(actor ! ReloadFollowing(_))
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import play.api.libs.json._
|
||||||
|
|
||||||
import actorApi._
|
import actorApi._
|
||||||
import lila.common.PimpedJson._
|
import lila.common.PimpedJson._
|
||||||
import lila.hub.actorApi.relation.ReloadFriends
|
import lila.hub.actorApi.relation.ReloadFollowing
|
||||||
import makeTimeout.large
|
import makeTimeout.large
|
||||||
|
|
||||||
object Handler {
|
object Handler {
|
||||||
|
@ -24,8 +24,8 @@ object Handler {
|
||||||
|
|
||||||
val baseController: Controller = {
|
val baseController: Controller = {
|
||||||
case ("p", _) ⇒ socket ! Ping(uid)
|
case ("p", _) ⇒ socket ! Ping(uid)
|
||||||
case ("friends", _) ⇒ userId foreach { u ⇒
|
case ("following_onlines", _) ⇒ userId foreach { u ⇒
|
||||||
hub.actor.relation ! ReloadFriends(u)
|
hub.actor.relation ! ReloadFollowing(u)
|
||||||
}
|
}
|
||||||
case msg ⇒ logwarn("Unhandled msg: " + msg)
|
case msg ⇒ logwarn("Unhandled msg: " + msg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ var lichess_sri = Math.random().toString(36).substring(5); // 8 chars
|
||||||
self.syncFriends();
|
self.syncFriends();
|
||||||
}, self.options.syncFriendsDelay);
|
}, self.options.syncFriendsDelay);
|
||||||
this.ws.send(JSON.stringify({
|
this.ws.send(JSON.stringify({
|
||||||
t: "friends"
|
t: "following_onlines"
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
handle: function(m) {
|
handle: function(m) {
|
||||||
|
@ -227,13 +227,13 @@ var lichess_sri = Math.random().toString(36).substring(5); // 8 chars
|
||||||
socket: null,
|
socket: null,
|
||||||
socketDefaults: {
|
socketDefaults: {
|
||||||
events: {
|
events: {
|
||||||
friends: function(data) {
|
following_onlines: function(data) {
|
||||||
$('#friend_box').friends("set", data);
|
$('#friend_box').friends("set", data);
|
||||||
},
|
},
|
||||||
friend_enters: function(name) {
|
following_enters: function(name) {
|
||||||
$('#friend_box').friends('enters', name);
|
$('#friend_box').friends('enters', name);
|
||||||
},
|
},
|
||||||
friend_leaves: function(name) {
|
following_leaves: function(name) {
|
||||||
$('#friend_box').friends('leaves', name);
|
$('#friend_box').friends('leaves', name);
|
||||||
},
|
},
|
||||||
n: function(e) {
|
n: function(e) {
|
||||||
|
@ -1274,7 +1274,7 @@ var lichess_sri = Math.random().toString(36).substring(5); // 8 chars
|
||||||
this.repaint();
|
this.repaint();
|
||||||
},
|
},
|
||||||
enters: function(user) {
|
enters: function(user) {
|
||||||
this.list.append(renderUser(user));
|
this.list.append(_renderUser(user));
|
||||||
this.repaint();
|
this.repaint();
|
||||||
},
|
},
|
||||||
leaves: function(user) {
|
leaves: function(user) {
|
||||||
|
|
1
todo
1
todo
|
@ -71,6 +71,7 @@ takeback/enpassant glitch http://en.lichess.org/forum/lichess-feedback/i-found-a
|
||||||
show teams in user mini
|
show teams in user mini
|
||||||
badges for top players in ELO and number of games
|
badges for top players in ELO and number of games
|
||||||
top menu is too long in french with long username
|
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
|
DEPLOY p21
|
||||||
----------
|
----------
|
||||||
|
|
Loading…
Reference in a new issue