From 0b3d25a890ad050e4c64a49da4b9e7f2b47b3568 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 8 Aug 2022 09:51:11 +0200 Subject: [PATCH] :sparkles: Make frontend use new cmd based repo methods for comments queries --- frontend/src/app/main/data/comments.cljs | 32 +++++++++---------- frontend/src/app/main/data/users.cljs | 4 +-- frontend/src/app/main/data/viewer.cljs | 8 ++--- .../app/main/data/workspace/persistence.cljs | 10 +++--- frontend/src/app/main/repo.cljs | 4 +++ 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/frontend/src/app/main/data/comments.cljs b/frontend/src/app/main/data/comments.cljs index cf9922b3d..b1b910a6f 100644 --- a/frontend/src/app/main/data/comments.cljs +++ b/frontend/src/app/main/data/comments.cljs @@ -93,8 +93,8 @@ objects (wsh/lookup-page-objects state page-id) frame-id (cph/frame-id-by-position objects (:position params)) params (assoc params :frame-id frame-id)] - (->> (rp/mutation :create-comment-thread params) - (rx/mapcat #(rp/query :comment-thread {:file-id (:file-id %) :id (:id %)})) + (->> (rp/mutation! :create-comment-thread params) + (rx/mapcat #(rp/cmd! :get-comment-thread {:file-id (:file-id %) :id (:id %)})) (rx/map created-thread-on-workspace) (rx/catch #(rx/throw {:type :comment-error}))))))) @@ -122,8 +122,8 @@ (let [share-id (-> state :viewer-local :share-id) frame-id (:frame-id params) params (assoc params :share-id share-id :frame-id frame-id)] - (->> (rp/mutation :create-comment-thread params) - (rx/mapcat #(rp/query :comment-thread {:file-id (:file-id %) :id (:id %) :share-id share-id})) + (->> (rp/mutation! :create-comment-thread params) + (rx/mapcat #(rp/cmd! :get-comment-thread {:file-id (:file-id %) :id (:id %) :share-id share-id})) (rx/map created-thread-on-viewer) (rx/catch #(rx/throw {:type :comment-error}))))))) @@ -135,7 +135,7 @@ (watch [_ state _] (let [done #(d/update-in-when % [:comment-threads id] assoc :count-unread-comments 0) share-id (-> state :viewer-local :share-id)] - (->> (rp/mutation :update-comment-thread-status {:id id :share-id share-id}) + (->> (rp/mutation! :update-comment-thread-status {:id id :share-id share-id}) (rx/map (constantly done)) (rx/catch #(rx/throw {:type :comment-error}))))))) @@ -153,7 +153,7 @@ ptk/WatchEvent (watch [_ state _] (let [share-id (-> state :viewer-local :share-id)] - (->> (rp/mutation :update-comment-thread {:id id :is-resolved is-resolved :share-id share-id}) + (->> (rp/mutation! :update-comment-thread {:id id :is-resolved is-resolved :share-id share-id}) (rx/catch #(rx/throw {:type :comment-error})) (rx/ignore)))))) @@ -168,7 +168,7 @@ (watch [_ state _] (let [share-id (-> state :viewer-local :share-id)] (rx/concat - (->> (rp/mutation :add-comment {:thread-id (:id thread) :content content :share-id share-id}) + (->> (rp/mutation! :add-comment {:thread-id (:id thread) :content content :share-id share-id}) (rx/map #(partial created %)) (rx/catch #(rx/throw {:type :comment-error}))) (rx/of (refresh-comment-thread thread)))))))) @@ -184,7 +184,7 @@ ptk/WatchEvent (watch [_ state _] (let [share-id (-> state :viewer-local :share-id)] - (->> (rp/mutation :update-comment {:id id :content content :share-id share-id}) + (->> (rp/mutation! :update-comment {:id id :content content :share-id share-id}) (rx/catch #(rx/throw {:type :comment-error})) (rx/ignore)))))) @@ -202,7 +202,7 @@ ptk/WatchEvent (watch [_ _ _] - (->> (rp/mutation :delete-comment-thread {:id id}) + (->> (rp/mutation! :delete-comment-thread {:id id}) (rx/catch #(rx/throw {:type :comment-error})) (rx/ignore))))) @@ -221,7 +221,7 @@ ptk/WatchEvent (watch [_ state _] (let [share-id (-> state :viewer-local :share-id)] - (->> (rp/mutation :delete-comment-thread {:id id :share-id share-id}) + (->> (rp/mutation! :delete-comment-thread {:id id :share-id share-id}) (rx/catch #(rx/throw {:type :comment-error})) (rx/ignore)))))) @@ -236,7 +236,7 @@ ptk/WatchEvent (watch [_ state _] (let [share-id (-> state :viewer-local :share-id)] - (->> (rp/mutation :delete-comment {:id id :share-id share-id}) + (->> (rp/mutation! :delete-comment {:id id :share-id share-id}) (rx/catch #(rx/throw {:type :comment-error})) (rx/ignore)))))) @@ -249,7 +249,7 @@ ptk/WatchEvent (watch [_ state _] (let [share-id (-> state :viewer-local :share-id)] - (->> (rp/query :comment-thread {:file-id file-id :id id :share-id share-id}) + (->> (rp/cmd! :get-comment-thread {:file-id file-id :id id :share-id share-id}) (rx/map #(partial fetched %)) (rx/catch #(rx/throw {:type :comment-error})))))))) @@ -272,7 +272,7 @@ ptk/WatchEvent (watch [_ state _] (let [share-id (-> state :viewer-local :share-id)] - (->> (rp/query :comment-threads {:file-id file-id :share-id share-id}) + (->> (rp/cmd! :get-comment-threads {:file-id file-id :share-id share-id}) (rx/map #(partial fetched %)) (rx/catch #(rx/throw {:type :comment-error})))))))) @@ -285,7 +285,7 @@ ptk/WatchEvent (watch [_ state _] (let [share-id (-> state :viewer-local :share-id)] - (->> (rp/query :comments {:thread-id thread-id :share-id share-id}) + (->> (rp/cmd! :get-comments {:thread-id thread-id :share-id share-id}) (rx/map #(partial fetched %)) (rx/catch #(rx/throw {:type :comment-error})))))))) @@ -297,7 +297,7 @@ ptk/WatchEvent (watch [_ _ _] (let [fetched #(assoc %2 :comment-threads (d/index-by :id %1))] - (->> (rp/query :unread-comment-threads {:team-id team-id}) + (->> (rp/cmd! :get-unread-comment-threads {:team-id team-id}) (rx/map #(partial fetched %)) (rx/catch #(rx/throw {:type :comment-error}))))))) @@ -426,7 +426,7 @@ ptk/WatchEvent (watch [_ _ _] (let [thread-id (:id thread)] - (->> (rp/mutation :update-comment-thread-frame {:id thread-id :frame-id frame-id}) + (->> (rp/mutation! :update-comment-thread-frame {:id thread-id :frame-id frame-id}) (rx/catch #(rx/throw {:type :comment-error :code :update-comment-thread-frame})) (rx/ignore))))))) diff --git a/frontend/src/app/main/data/users.cljs b/frontend/src/app/main/data/users.cljs index 104b2619e..a0c6bfdea 100644 --- a/frontend/src/app/main/data/users.cljs +++ b/frontend/src/app/main/data/users.cljs @@ -445,7 +445,7 @@ (ptk/reify ::fetch-team-users ptk/WatchEvent (watch [_ _ _] - (->> (rp/query :team-users {:team-id team-id}) + (->> (rp/query! :team-users {:team-id team-id}) (rx/map #(partial fetched %))))))) (defn fetch-file-comments-users @@ -459,7 +459,7 @@ ptk/WatchEvent (watch [_ state _] (let [share-id (-> state :viewer-local :share-id)] - (->> (rp/query :file-comments-users {:team-id team-id :share-id share-id}) + (->> (rp/command! :get-profiles-for-file-comments {:team-id team-id :share-id share-id}) (rx/map #(partial fetched %)))))))) ;; --- EVENT: request-account-deletion diff --git a/frontend/src/app/main/data/viewer.cljs b/frontend/src/app/main/data/viewer.cljs index 54c042222..d920b7685 100644 --- a/frontend/src/app/main/data/viewer.cljs +++ b/frontend/src/app/main/data/viewer.cljs @@ -102,7 +102,7 @@ (watch [_ _ _] (let [params' (cond-> {:file-id file-id} (uuid? share-id) (assoc :share-id share-id))] - (->> (rp/query :view-only-bundle params') + (->> (rp/query! :view-only-bundle params') (rx/mapcat (fn [{:keys [fonts] :as bundle}] (rx/of (df/fonts-fetched fonts) @@ -156,7 +156,7 @@ (ptk/reify ::fetch-comment-threads ptk/WatchEvent (watch [_ _ _] - (->> (rp/query :comment-threads {:file-id file-id :share-id share-id}) + (->> (rp/cmd! :get-comment-threads {:file-id file-id :share-id share-id}) (rx/map #(partial fetched %)) (rx/catch on-error)))))) @@ -167,7 +167,7 @@ (ptk/reify ::refresh-comment-thread ptk/WatchEvent (watch [_ _ _] - (->> (rp/query :comment-thread {:file-id file-id :id id}) + (->> (rp/cmd! :get-comment-thread {:file-id file-id :id id}) (rx/map #(partial fetched %))))))) (defn fetch-comments @@ -178,7 +178,7 @@ (ptk/reify ::retrieve-comments ptk/WatchEvent (watch [_ _ _] - (->> (rp/query :comments {:thread-id thread-id}) + (->> (rp/cmd! :get-comments {:thread-id thread-id}) (rx/map #(partial fetched %))))))) ;; --- Zoom Management diff --git a/frontend/src/app/main/data/workspace/persistence.cljs b/frontend/src/app/main/data/workspace/persistence.cljs index 445f5001c..e88d0c750 100644 --- a/frontend/src/app/main/data/workspace/persistence.cljs +++ b/frontend/src/app/main/data/workspace/persistence.cljs @@ -262,11 +262,11 @@ ptk/WatchEvent (watch [_ state _] (let [share-id (-> state :viewer-local :share-id)] - (->> (rx/zip (rp/query :file-raw {:id file-id}) - (rp/query :team-users {:file-id file-id}) - (rp/query :project {:id project-id}) - (rp/query :file-libraries {:file-id file-id}) - (rp/query :file-comments-users {:file-id file-id :share-id share-id})) + (->> (rx/zip (rp/query! :file-raw {:id file-id}) + (rp/query! :team-users {:file-id file-id}) + (rp/query! :project {:id project-id}) + (rp/query! :file-libraries {:file-id file-id}) + (rp/cmd! :get-profiles-for-file-comments {:file-id file-id :share-id share-id})) (rx/take 1) (rx/map (fn [[file-raw users project libraries file-comments-users]] {:file-raw file-raw diff --git a/frontend/src/app/main/repo.cljs b/frontend/src/app/main/repo.cljs index 3028d7c2d..a5e0b115a 100644 --- a/frontend/src/app/main/repo.cljs +++ b/frontend/src/app/main/repo.cljs @@ -127,6 +127,10 @@ ([id] (command id {})) ([id params] (command id params))) +(defn cmd! + ([id] (command id {})) + ([id params] (command id params))) + (defmethod command :login-with-oidc [_ {:keys [provider] :as params}] (let [uri (u/join base-uri "api/auth/oauth/" (d/name provider))