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:
commit
d2f23fd95e
1 changed files with 11 additions and 2 deletions
|
@ -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)))))))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
Loading…
Add table
Reference in a new issue