0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-25 07:58:49 -05:00

Detach all assets when unlinking an external lib

This commit is contained in:
Andrés Moya 2021-07-27 16:26:19 +02:00 committed by Andrey Antukh
parent c6fe19c321
commit 259b405526
3 changed files with 13 additions and 6 deletions

View file

@ -594,7 +594,7 @@
ptk/UpdateEvent
(update [_ state]
(if (not= library-id (:current-file-id state))
(assoc-in state [:workspace-libraries library-id :synced-at] (dt/now))
(d/assoc-in-when state [:workspace-libraries library-id :synced-at] (dt/now))
state))
ptk/WatchEvent

View file

@ -326,13 +326,16 @@
(defn unlink-file-from-library
[file-id library-id]
(ptk/reify ::unlink-file-from-library
ptk/UpdateEvent
(update [_ state]
(d/dissoc-in state [:workspace-libraries library-id]))
ptk/WatchEvent
(watch [_ _ _]
(let [unlinked #(d/dissoc-in % [:workspace-libraries library-id])
params {:file-id file-id
:library-id library-id}]
(let [params {:file-id file-id
:library-id library-id}]
(->> (rp/mutation :unlink-file-from-library params)
(rx/map (constantly unlinked)))))))
(rx/ignore))))))
;; --- Upload File Media objects

View file

@ -75,7 +75,11 @@
(mf/use-callback (mf/deps file) #(st/emit! (dw/link-file-to-library (:id file) %)))
unlink-library
(mf/use-callback (mf/deps file) #(st/emit! (dw/unlink-file-from-library (:id file) %)))]
(mf/use-callback
(mf/deps file)
(fn [library-id]
(st/emit! (dw/unlink-file-from-library (:id file) library-id)
(dwl/sync-file (:id file) library-id))))]
[:*
[:div.section
[:div.section-title (tr "workspace.libraries.in-this-file")]