0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

Merge pull request #150 from uxbox/bug/create-file-from-recent

Update recent-files when creating or deleting a file
This commit is contained in:
Andrey Antukh 2020-03-24 19:22:36 +01:00 committed by GitHub
commit d2f23fd95e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;