From 8629dc6b2c73efa59c84db56d5625d3981ab94dc Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 14 Sep 2026 13:23:44 +0200 Subject: [PATCH] :fire: Remove unused comment profiles code in the frontend (#11624) * :fire: 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 * :fire: 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 --- frontend/src/app/main/data/comments.cljs | 14 ++------------ frontend/src/app/main/data/profile.cljs | 14 -------------- frontend/src/app/main/data/viewer.cljs | 3 +-- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/frontend/src/app/main/data/comments.cljs b/frontend/src/app/main/data/comments.cljs index a69d759272..1d19adffeb 100644 --- a/frontend/src/app/main/data/comments.cljs +++ b/frontend/src/app/main/data/comments.cljs @@ -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 diff --git a/frontend/src/app/main/data/profile.cljs b/frontend/src/app/main/data/profile.cljs index 9d6db2101d..99b52a4afd 100644 --- a/frontend/src/app/main/data/profile.cljs +++ b/frontend/src/app/main/data/profile.cljs @@ -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? diff --git a/frontend/src/app/main/data/viewer.cljs b/frontend/src/app/main/data/viewer.cljs index c5f20ce24d..cbf63f4773 100644 --- a/frontend/src/app/main/data/viewer.cljs +++ b/frontend/src/app/main/data/viewer.cljs @@ -44,8 +44,7 @@ :selected #{} :collapsed #{} :hover nil - :share-id "" - :file-comments-users []}) + :share-id ""}) (declare fetch-comment-threads) (declare fetch-bundle)