From 7d2b420da17f5e27745a264d94334674fa467a56 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 8 Oct 2026 09:50:17 +0000 Subject: [PATCH] :recycle: Rename close! param and avoid assoc-in Rename the `start-relay` callback param from `close!` to `close-fn`, following the no-new-`!` direction and matching the sibling `on-forward` callback that already carries no `!`. Replace the two fixed-path `assoc-in` calls in `register-connection` and `unregister-connection` with `update` plus `assoc`, as asked on the PR. Both parent maps always exist in the atom, so the behavior is identical. AI-assisted-by: muse-spark-1.3-contributor --- backend/src/app/http/websocket.clj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/app/http/websocket.clj b/backend/src/app/http/websocket.clj index 206125cbad..3235317def 100644 --- a/backend/src/app/http/websocket.clj +++ b/backend/src/app/http/websocket.clj @@ -61,7 +61,7 @@ (swap! state (fn [st] (-> st - (assoc-in [:connections id] wsp) + (update :connections assoc id wsp) (cond-> profile-id (update-in [:by-profile profile-id] (fnil conj #{}) id))))))) @@ -76,7 +76,7 @@ indexed (disj (get-in st [:by-profile owner] #{}) id)] (cond-> (assoc st :connections (dissoc connections id)) (and owner (seq indexed)) - (assoc-in [:by-profile owner] indexed) + (update :by-profile assoc owner indexed) (and owner (empty? indexed)) (update :by-profile dissoc owner)))))) @@ -242,12 +242,12 @@ (defn- start-relay "Forwards `channel` into the client output channel of `wsp`, and keeps a re-check of `check-access` running on the interval. When access no - longer holds, `close!` tears the subscription down, which closes the + longer holds, `close-fn` tears the subscription down, which closes the channel and ends the loop. `on-forward` runs for every forwarded message, which is how the file relay announces presence." - [{:keys [::ws/output-ch] :as wsp} channel check-access close! on-forward] + [{:keys [::ws/output-ch] :as wsp} channel check-access close-fn on-forward] (schedule-revalidation #(not (sp/closed? channel)) (inst-ms (revalidation-interval)) (fn [] @@ -255,7 +255,7 @@ (l/info :hint "closing websocket subscription on re-check" :profile-id (::profile-id wsp)) - (close!)))) + (close-fn)))) (sp/go-loop [] ;; nil means the channel was closed, which means the subscription ;; is gone and the relay ends.