From 0e8a62769d9cc7210573ef588420828cc7fdc4e9 Mon Sep 17 00:00:00 2001 From: Oguz Han Asnaz Date: Sat, 29 Jul 2023 20:26:21 +0200 Subject: [PATCH] Bind lobby update pausing to games-list component's visibility --- src/cljs/nr/lobby.cljs | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/cljs/nr/lobby.cljs b/src/cljs/nr/lobby.cljs index c9e2b47bef..ab7a164402 100644 --- a/src/cljs/nr/lobby.cljs +++ b/src/cljs/nr/lobby.cljs @@ -21,8 +21,6 @@ [taoensso.sente :as sente])) (defmethod ws/event-msg-handler :lobby/list [{data :?data}] - (when (get-in @app-state [:current-game :started] false) ; Pause lobby updates if in game - (ws/lobby-updates-pause!)) (swap! app-state assoc :games data)) (defmethod ws/event-msg-handler :lobby/state [{data :?data}] @@ -223,16 +221,27 @@ [load-replay-button s games current-game user]])]) (defn games-list-panel [state games current-game user visible-formats] - [:div.games - [button-bar state games current-game user visible-formats] - (if @ws/lobby-updates-state - (if (= "angel-arena" (:room @state)) - [angel-arena/game-list state {:games games - :current-game current-game}] - [game-list state user games current-game]) - [:div - "Lobby updates halted." ; this should never be visible - [:button {:on-click #(ws/lobby-updates-continue!)} "Reenable lobby updates"]])]) + (r/create-class + {:display-name "games-list" + :component-did-mount + (fn [] + (ws/lobby-updates-continue!)) + :component-will-unmount + (fn [] + (ws/lobby-updates-pause!)) + + :reagent-render + (fn [] + [:div.games + [button-bar state games current-game user visible-formats] + (if @ws/lobby-updates-state + (if (= "angel-arena" (:room @state)) + [angel-arena/game-list state {:games games + :current-game current-game}] + [game-list state user games current-game]) + [:div + "Lobby updates halted." ; this should never be visible + [:button {:on-click #(ws/lobby-updates-continue!)} "Reenable lobby updates"]])])})) (defn right-panel [state decks current-game user]