diff --git a/frontend/src/app/main/data/workspace/changes.cljs b/frontend/src/app/main/data/workspace/changes.cljs index 37a95099a..dbb4830be 100644 --- a/frontend/src/app/main/data/workspace/changes.cljs +++ b/frontend/src/app/main/data/workspace/changes.cljs @@ -159,10 +159,8 @@ ([changes undo-changes] (commit-changes changes undo-changes {})) ([changes undo-changes {:keys [save-undo? - commit-local? file-id] - :or {save-undo? true - commit-local? false} + :or {save-undo? true} :as opts}] (us/assert ::cp/changes changes) (us/assert ::cp/changes undo-changes) @@ -173,23 +171,20 @@ (let [error (volatile! nil)] (ptk/reify ::commit-changes cljs.core/IDeref - (-deref [_] {:file-id file-id :changes changes}) + (-deref [_] + {:file-id file-id + :changes changes}) ptk/UpdateEvent (update [_ state] (let [current-file-id (get state :current-file-id) file-id (or file-id current-file-id) - path1 (if (= file-id current-file-id) - [:workspace-file :data] - [:workspace-libraries file-id :data]) - path2 (if (= file-id current-file-id) + path (if (= file-id current-file-id) [:workspace-data] [:workspace-libraries file-id :data])] (try (us/assert ::spec/changes changes) - (let [state (update-in state path1 cp/process-changes changes false)] - (cond-> state - commit-local? (update-in path2 cp/process-changes changes false))) + (update-in state path cp/process-changes changes false) (catch :default e (vreset! error e) state)))) diff --git a/frontend/src/app/main/data/workspace/persistence.cljs b/frontend/src/app/main/data/workspace/persistence.cljs index 7b5d4433b..627470a71 100644 --- a/frontend/src/app/main/data/workspace/persistence.cljs +++ b/frontend/src/app/main/data/workspace/persistence.cljs @@ -211,8 +211,7 @@ (if (= file-id (:current-file-id state)) (-> state (update-in [:workspace-file :revn] max revn) - (update :workspace-data cp/process-changes changes) - (update-in [:workspace-file :data] cp/process-changes changes)) + (update :workspace-data cp/process-changes changes)) (-> state (update-in [:workspace-libraries file-id :revn] max revn) (update-in [:workspace-libraries file-id :data] diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs index 4159948d6..41eff4d51 100644 --- a/frontend/src/app/main/refs.cljs +++ b/frontend/src/app/main/refs.cljs @@ -138,8 +138,8 @@ (def workspace-file-colors (l/derived (fn [state] - (when-let [file (:workspace-file state)] - (->> (get-in file [:data :colors]) + (when-let [file (:workspace-data state)] + (->> (:colors file) (d/mapm #(assoc %2 :file-id (:id file)))))) st/state)) @@ -150,8 +150,8 @@ (def workspace-file-typography (l/derived (fn [state] - (when-let [file (:workspace-file state)] - (get-in file [:data :typographies]))) + (when-let [file (:workspace-data state)] + (:typographies file))) st/state)) (def workspace-project diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs index cac7375bf..fe111fa94 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs @@ -811,9 +811,9 @@ (defn file-colors-ref [id] (l/derived (fn [state] - (let [wfile (:workspace-file state)] + (let [wfile (:workspace-data state)] (if (= (:id wfile) id) - (vals (get-in wfile [:data :colors])) + (vals (get-in wfile [:colors])) (vals (get-in state [:workspace-libraries id :data :colors]))))) st/state =)) @@ -821,27 +821,27 @@ (defn file-media-ref [id] (l/derived (fn [state] - (let [wfile (:workspace-file state)] + (let [wfile (:workspace-data state)] (if (= (:id wfile) id) - (vals (get-in wfile [:data :media])) + (vals (get-in wfile [:media])) (vals (get-in state [:workspace-libraries id :data :media]))))) st/state =)) (defn file-components-ref [id] (l/derived (fn [state] - (let [wfile (:workspace-file state)] + (let [wfile (:workspace-data state)] (if (= (:id wfile) id) - (vals (get-in wfile [:data :components])) + (vals (get-in wfile [:components])) (vals (get-in state [:workspace-libraries id :data :components]))))) st/state =)) (defn file-typography-ref [id] (l/derived (fn [state] - (let [wfile (:workspace-file state)] + (let [wfile (:workspace-data state)] (if (= (:id wfile) id) - (vals (get-in wfile [:data :typographies])) + (vals (get-in wfile [:typographies])) (vals (get-in state [:workspace-libraries id :data :typographies]))))) st/state =)) diff --git a/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs b/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs index 2cf441813..ae5ac0ed8 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs @@ -164,7 +164,7 @@ (defn- make-page-ref [page-id] (l/derived (fn [state] - (let [page (get-in state [:workspace-file :data :pages-index page-id])] + (let [page (get-in state [:workspace-data :pages-index page-id])] (select-keys page [:id :name]))) st/state =))