diff --git a/modules/api/src/main/Context.scala b/modules/api/src/main/Context.scala
index 3bc3693745..55acd5aec2 100644
--- a/modules/api/src/main/Context.scala
+++ b/modules/api/src/main/Context.scala
@@ -8,7 +8,7 @@ import lila.user.{ UserContext, HeaderUserContext, BodyUserContext }
case class PageData(
friends: List[lila.common.LightUser],
- friendsPlaying: List[lila.common.LightUser],
+ friendsPlaying: Set[String],
teamNbRequests: Int,
nbChallenges: Int,
nbNotifications: Int,
@@ -18,7 +18,7 @@ case class PageData(
object PageData {
- val default = PageData(Nil, Nil, 0, 0, 0, Pref.default, false, false)
+ val default = PageData(Nil, Set.empty, 0, 0, 0, Pref.default, false, false)
def anon(blindMode: Boolean) = default.copy(blindMode = blindMode)
}
diff --git a/modules/hub/src/main/actorApi.scala b/modules/hub/src/main/actorApi.scala
index fd5bb7e622..9c72f80d2a 100644
--- a/modules/hub/src/main/actorApi.scala
+++ b/modules/hub/src/main/actorApi.scala
@@ -185,7 +185,7 @@ case class Remove(gameId: String)
package relation {
case class ReloadOnlineFriends(userId: String)
case class GetOnlineFriends(userId: String)
-case class OnlineFriends(users: List[LightUser], usersPlaying: List[LightUser])
+case class OnlineFriends(users: List[LightUser], usersPlaying: Set[String])
case class Block(u1: String, u2: String)
case class UnBlock(u1: String, u2: String)
}
diff --git a/modules/relation/src/main/RelationActor.scala b/modules/relation/src/main/RelationActor.scala
index 96b8554620..f6f90ff71e 100644
--- a/modules/relation/src/main/RelationActor.scala
+++ b/modules/relation/src/main/RelationActor.scala
@@ -21,7 +21,7 @@ private[relation] final class RelationActor(
private var onlines = Map[ID, LightUser]()
- private var onlinePlayings = Map[ID, LightUser]()
+ private var onlinePlayings = Set[ID]()
override def preStart(): Unit = {
context.system.lilaBus.subscribe(self, 'startGame)
@@ -41,7 +41,7 @@ private[relation] final class RelationActor(
case ReloadOnlineFriends(userId) => onlineFriends(userId) foreach {
case OnlineFriends(users, friendsPlaying) =>
bus.publish(SendTo(userId, "following_onlines", users.map(_.titleName)), 'users)
- bus.publish(SendTo(userId, "following_playings", friendsPlaying.map(_.titleName)), 'users)
+ bus.publish(SendTo(userId, "following_playings", friendsPlaying), 'users)
}
case NotifyMovement =>
@@ -62,7 +62,7 @@ private[relation] final class RelationActor(
case msg: lila.game.actorApi.StartGame =>
val usersPlaying = getGameUsers(msg.game)
- onlinePlayings = onlinePlayings ++ usersPlaying.map(u => u.id -> u)
+ onlinePlayings = onlinePlayings ++ usersPlaying.map(_.id)
notifyFollowers(usersPlaying, "following_playing")
}
@@ -80,8 +80,8 @@ private[relation] final class RelationActor(
OnlineFriends(friends, friendsPlaying)
}
- private def getFriendsPlaying(friends: List[LightUser]): List[LightUser] = {
- friends.filter(p => onlinePlayings.contains(p.id))
+ private def getFriendsPlaying(friends: List[LightUser]): Set[String] = {
+ friends.filter(p => onlinePlayings.contains(p.id)).map(_.id).toSet
}
private def notifyFollowers(users: List[LightUser], message: String) {
diff --git a/public/javascripts/main.js b/public/javascripts/main.js
index 045a562dce..eaf021c31b 100644
--- a/public/javascripts/main.js
+++ b/public/javascripts/main.js
@@ -1154,12 +1154,17 @@ lichess.notifyApp = (function() {
},
_setPlaying: function(userName, playing) {
- var user = this.users.find(function(u) {
- return u.name === userName;
+ var isSameUser = function(userName, user) {
+ var id = $.fp.contains(user.name, ' ') ? user.name.split(' ')[1] : user.name;
+ return id === userName;
+ }
+
+ var user = this.users.filter(function(u) {
+ return isSameUser(userName, u);
});
- if (user) {
- user["playing"] = playing;
+ if (user.length > 0) {
+ user[0]["playing"] = playing;
}
},