mirror of
https://github.com/penpot/penpot.git
synced 2026-09-17 01:16:13 +00:00
🔥 Remove unused comment profiles code in the frontend (#11624)
* 🔥 Remove unused comment profiles fan-out in dashboard The dashboard event retrieve-unread-comment-threads issued one get-profiles-for-file-comments call per distinct file id and stored the result in :current-team-comments-users, a state key no one reads. The dashboard renders each thread author from the thread payload via get-owner, so the fan-out was N+1 dead work. Drop the per-file branch and the state write; the event now issues a single get-unread-comment-threads call. AI-assisted-by: deepseek-flash * 🔥 Remove unused file comments users event and state fetch-file-comments-users had no callers and passed a :team-id where get-profiles-for-file-comments requires :file-id. Its only effect was writing :file-comments-users, a viewer state key no one reads. Remove the event and the unused state key. The viewer still loads comment profiles through fetch-profiles. AI-assisted-by: deepseek-flash
This commit is contained in:
parent
8ae188ad0b
commit
8629dc6b2c
@ -441,7 +441,6 @@
|
||||
(rx/catch #(rx/throw {:type :comment-error}))))))))
|
||||
|
||||
|
||||
;; FIXME: revisit
|
||||
(defn retrieve-unread-comment-threads
|
||||
"A event used mainly in dashboard for retrieve all unread threads of a team."
|
||||
[team-id]
|
||||
@ -449,18 +448,9 @@
|
||||
(ptk/reify ::retrieve-unread-comment-threads
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(let [fetched-comments #(assoc %2 :comment-threads (d/index-by :id %1))
|
||||
fetched-users #(assoc %2 :current-team-comments-users %1)]
|
||||
(let [fetched-comments #(assoc %2 :comment-threads (d/index-by :id %1))]
|
||||
(->> (rp/cmd! :get-unread-comment-threads {:team-id team-id})
|
||||
(rx/merge-map
|
||||
(fn [comments]
|
||||
(rx/concat
|
||||
(rx/of (partial fetched-comments comments))
|
||||
|
||||
(->> (rx/from (into #{} (map :file-id) comments))
|
||||
(rx/merge-map #(rp/cmd! :get-profiles-for-file-comments {:file-id %}))
|
||||
(rx/reduce #(merge %1 (d/index-by :id %2)) {})
|
||||
(rx/map #(partial fetched-users %))))))
|
||||
(rx/map #(partial fetched-comments %))
|
||||
(rx/catch #(rx/throw {:type :comment-error})))))))
|
||||
|
||||
(defn mark-all-threads-as-read
|
||||
|
||||
@ -377,20 +377,6 @@
|
||||
(js/console.error "delete-photo failed" cause)
|
||||
(rx/of (refresh-profile))))))))
|
||||
|
||||
(defn fetch-file-comments-users
|
||||
[{:keys [team-id]}]
|
||||
(assert (uuid? team-id) "expected a valid uuid for `team-id`")
|
||||
(letfn [(fetched [users state]
|
||||
(->> users
|
||||
(d/index-by :id)
|
||||
(assoc state :file-comments-users)))]
|
||||
(ptk/reify ::fetch-file-comments-users
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [share-id (-> state :viewer-local :share-id)]
|
||||
(->> (rp/cmd! :get-profiles-for-file-comments {:team-id team-id :share-id share-id})
|
||||
(rx/map #(partial fetched %))))))))
|
||||
|
||||
;; --- EVENT: request-account-deletion
|
||||
|
||||
(def profile-deleted-event?
|
||||
|
||||
@ -44,8 +44,7 @@
|
||||
:selected #{}
|
||||
:collapsed #{}
|
||||
:hover nil
|
||||
:share-id ""
|
||||
:file-comments-users []})
|
||||
:share-id ""})
|
||||
|
||||
(declare fetch-comment-threads)
|
||||
(declare fetch-bundle)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user