mirror of
https://github.com/penpot/penpot.git
synced 2026-10-29 22:10:34 +00:00
♻️ 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
This commit is contained in:
parent
97193da78e
commit
7d2b420da1
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user