From 2e1bbd839767aa1b03c5f7e213f66a61c3e62c32 Mon Sep 17 00:00:00 2001 From: rcmerci Date: Tue, 17 Jun 2025 21:21:16 +0800 Subject: [PATCH] fix(rtc): keep online-users info when reuse same ws --- src/main/frontend/worker/rtc/core.cljs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/frontend/worker/rtc/core.cljs b/src/main/frontend/worker/rtc/core.cljs index 429ab3c113..264127ce43 100644 --- a/src/main/frontend/worker/rtc/core.cljs +++ b/src/main/frontend/worker/rtc/core.cljs @@ -197,6 +197,16 @@ (finally (reset! *rtc-lock nil))))) +(def ^:private *graph-uuid->*online-users (atom {})) +(defn- get-or-create-*online-users + [graph-uuid] + (assert (uuid? graph-uuid)) + (if-let [*online-users (get @*graph-uuid->*online-users graph-uuid)] + *online-users + (let [*online-users (atom nil)] + (swap! *graph-uuid->*online-users assoc graph-uuid *online-users) + *online-users))) + (declare new-task--inject-users-info) (defn- create-rtc-loop "Return a map with [:rtc-state-flow :rtc-loop-task :*rtc-auto-push? :onstarted-task] @@ -208,7 +218,7 @@ *auto-push? (atom auto-push?) *remote-profile? (atom false) *last-calibrate-t (atom nil) - *online-users (atom nil) + *online-users (get-or-create-*online-users graph-uuid) *assets-sync-loop-canceler (atom nil) *server-schema-version (atom nil) started-dfv (m/dfv)