From 0868b6dcf4b71311789e1fce6c8a5a7bd65ea01b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Tue, 24 Mar 2020 15:33:46 +0100 Subject: [PATCH] Update recent-files when creating or deleting a file --- frontend/src/uxbox/main/data/dashboard.cljs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/uxbox/main/data/dashboard.cljs b/frontend/src/uxbox/main/data/dashboard.cljs index 0dafbe6c5..b9ec00ff7 100644 --- a/frontend/src/uxbox/main/data/dashboard.cljs +++ b/frontend/src/uxbox/main/data/dashboard.cljs @@ -291,7 +291,11 @@ (ptk/reify ::delete-file ptk/UpdateEvent (update [_ state] - (update state :files dissoc id)) + (let [project-id (get-in state [:files id :project-id]) + recent-project-files (get-in state [:recent-file-ids project-id] [])] + (-> state + (update :files dissoc id) + (assoc-in [:recent-file-ids project-id] (remove #(= % id) recent-project-files))))) ptk/WatchEvent (watch [_ state s] @@ -336,7 +340,12 @@ (ptk/reify ::file-created ptk/UpdateEvent (update [this state] - (update state :files assoc (:id data) data)))) + (let [project-id (:project-id data) + file-id (:id data) + recent-project-files (get-in state [:recent-file-ids project-id] [])] + (-> state + (assoc-in [:files file-id] data) + (assoc-in [:recent-file-ids project-id] (conj recent-project-files file-id))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;