Skip to content

Commit

Permalink
refactor: simplify remove-query-component!
Browse files Browse the repository at this point in the history
  • Loading branch information
gyk committed Nov 20, 2020
1 parent 1f3573f commit e2d7cac
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/frontend/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@

(defn remove-query-component!
[component]
(let [ks (->> (filter (fn [[_ components]]
(contains? (set components) component))
@query-components)
(map first))]
(doseq [k ks]
(swap! query-components update k (fn [components]
(remove #(= component %) components)))
(when (zero? (count (get @query-components k))) ; no subscribed components
(swap! query-components dissoc k)
(remove-q! k)))))
(reset!
query-components
(->> (for [[k components] @query-components
:let [new-components (remove #(= component %) components)]]
(if (empty? new-components) ; no subscribed components
(do (remove-q! k)
nil)
[k new-components]))
(keep identity)
(into {}))))

(defn get-page-blocks-cache-atom
[repo page-id]
Expand Down

0 comments on commit e2d7cac

Please sign in to comment.