Move projects queries and mutations to commands

This commit is contained in:
Andrey Antukh 2023-01-16 17:13:17 +01:00
parent dc77c6b655
commit dba7a9d424
14 changed files with 311 additions and 137 deletions

View file

@ -185,7 +185,7 @@
ptk/WatchEvent
(watch [_ state _]
(let [team-id (:current-team-id state)]
(->> (rp/query! :projects {:team-id team-id})
(->> (rp/cmd! :get-projects {:team-id team-id})
(rx/map projects-fetched))))))
;; --- EVENT: search
@ -671,7 +671,7 @@
{:keys [on-success on-error]
:or {on-success identity
on-error rx/throw}} (meta params)]
(->> (rp/mutation! :create-project params)
(->> (rp/cmd! :create-project params)
(rx/tap on-success)
(rx/map project-created)
(rx/catch on-error))))))
@ -733,7 +733,7 @@
(watch [_ state _]
(let [project (get-in state [:dashboard-projects id])
params (select-keys project [:id :is-pinned :team-id])]
(->> (rp/mutation :update-project-pin params)
(->> (rp/cmd! :update-project-pin params)
(rx/ignore))))))
;; --- EVENT: rename-project
@ -751,7 +751,7 @@
ptk/WatchEvent
(watch [_ _ _]
(let [params {:id id :name name}]
(->> (rp/mutation :rename-project params)
(->> (rp/cmd! :rename-project params)
(rx/ignore))))))
;; --- EVENT: delete-project
@ -766,7 +766,7 @@
ptk/WatchEvent
(watch [_ _ _]
(->> (rp/mutation :delete-project {:id id})
(->> (rp/cmd! :delete-project {:id id})
(rx/ignore)))))
;; --- EVENT: delete-file
@ -1077,7 +1077,7 @@
action-name (if in-project? :create-file :create-project)
action (if in-project? file-created project-created)]
(->> (rp/mutation! action-name params)
(->> (rp/cmd! action-name params)
(rx/map action))))))
(defn open-selected-file

View file

@ -267,7 +267,7 @@
(->> (rx/zip (rp/cmd! :get-file {:id file-id :features features})
(rp/cmd! :get-file-object-thumbnails {:file-id file-id})
(rp/query! :project {:id project-id})
(rp/cmd! :get-project {:id project-id})
(rp/cmd! :get-team-users {:file-id file-id})
(rp/cmd! :get-profiles-for-file-comments {:file-id file-id :share-id share-id}))
(rx/take 1)
@ -1564,7 +1564,7 @@
(into (d/ordered-set)))
undo-id (js/Symbol)]
(rx/of (dwu/start-undo-transaction undo-id)
(rx/of (dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(dws/select-shapes selected)
(ptk/data-event :layout/update [frame-id])

View file

@ -207,7 +207,7 @@
(mf/deps show?)
(fn []
(when show?
(->> (rp/query! :all-projects)
(->> (rp/cmd! :get-all-projects)
(rx/map group-by-team)
(rx/subs #(when (mf/ref-val mounted-ref)
(reset! teams %)))))))