diff --git a/modules/game/src/main/Featured.scala b/modules/game/src/main/Featured.scala index db4e24e5e5..04f0f902f2 100644 --- a/modules/game/src/main/Featured.scala +++ b/modules/game/src/main/Featured.scala @@ -37,7 +37,7 @@ final class Featured( oneId = game.id.some rendererActor ? actorApi.RenderFeaturedJs(game) onSuccess { case html: Html => - bus.publish(lila.hub.actorApi.game.ChangeFeatured(html), 'changeFeaturedGame) + bus.publish(lila.hub.actorApi.game.ChangeFeatured(game.id, html), 'changeFeaturedGame) } GameRepo setTv game.id } diff --git a/modules/hub/src/main/actorApi.scala b/modules/hub/src/main/actorApi.scala index dc471f9017..b28ae4c298 100644 --- a/modules/hub/src/main/actorApi.scala +++ b/modules/hub/src/main/actorApi.scala @@ -95,7 +95,7 @@ case class Propagate(data: Atom, propagations: List[Propagation] = Nil) { } package game { -case class ChangeFeatured(html: Html) +case class ChangeFeatured(id: String, html: Html) case object Count } diff --git a/modules/round/src/main/TvBroadcast.scala b/modules/round/src/main/TvBroadcast.scala index 60a36e30f3..0575df747a 100644 --- a/modules/round/src/main/TvBroadcast.scala +++ b/modules/round/src/main/TvBroadcast.scala @@ -17,17 +17,21 @@ private final class TvBroadcast extends Actor { private val (enumerator, channel) = Concurrent.broadcast[JsValue] + private var featuredId = none[String] + def receive = { case TvBroadcast.GetEnumerator => sender ! enumerator - case ChangeFeatured(html) => + case ChangeFeatured(id, html) => + featuredId = id.some channel push makeMessage("featured", Json.obj("html" -> html.toString)) - case move: MoveEvent => channel push makeMessage("fen", Json.obj( - "fen" -> move.fen, - "lm" -> move.move - )) + case move: MoveEvent if Some(move.gameId) == featuredId => + channel push makeMessage("fen", Json.obj( + "fen" -> move.fen, + "lm" -> move.move + )) } } diff --git a/modules/socket/src/main/SocketActor.scala b/modules/socket/src/main/SocketActor.scala index 0a098f0250..9bb85520e7 100644 --- a/modules/socket/src/main/SocketActor.scala +++ b/modules/socket/src/main/SocketActor.scala @@ -61,7 +61,7 @@ abstract class SocketActor[M <: SocketMember](uidTtl: Duration) extends Socket w // the actor instance must subscribe to 'changeFeaturedGame to receive this message // context.system.lilaBus.subscribe(self, 'changeFeaturedGame) - case ChangeFeatured(html) => notifyFeatured(html) + case ChangeFeatured(_, html) => notifyFeatured(html) } def receive = receiveSpecific orElse receiveGeneric