diff --git a/js/src/main/scala/cs214/webapp/client/graphics/WebClientAppInstance.scala b/js/src/main/scala/cs214/webapp/client/graphics/WebClientAppInstance.scala index 423ab4263029d39fc2c4f37ebc3ea44a3bb48f18..a01109695f445f8e5d98b7577c48e11fd62eeb55 100644 --- a/js/src/main/scala/cs214/webapp/client/graphics/WebClientAppInstance.scala +++ b/js/src/main/scala/cs214/webapp/client/graphics/WebClientAppInstance.scala @@ -13,6 +13,9 @@ abstract class WebClientAppInstance[Event, View]( sendMessage: ujson.Value => Unit, target: Target ) extends StateMachineClientAppInstance[Event, View](userId, sendMessage), DOMClientUI[View], PatchableUI: + /** The currently-rendered view, if one exists. */ + private var currentView: Option[View] = None + /** Renders a [[View]] received from the server. The method also takes a * [[UserId]] to get information on the context and an [[onEvent]] callback * which it uses to send server events when specific actions are triggered on @@ -27,7 +30,9 @@ abstract class WebClientAppInstance[Event, View]( protected def render(userId: UserId, view: View): Frag override def displayView(view: View): Unit = - patchUI(target, render(userId, view)) + if Some(view) != currentView then + currentView = Some(view) + patchUI(target, render(userId, view)) override def patchUI(target: dom.Element, fr: Frag): Unit = target.replaceChildren(fr.render)