diff --git a/CHANGES.md b/CHANGES.md index 2b95e7223..5631282a0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -48,6 +48,7 @@ - Fix problem with some texts desynchronization [Taiga #9379](https://tree.taiga.io/project/penpot/issue/9379) - Fix problem with reoder grid layers [#5446](https://github.com/penpot/penpot/issues/5446) +- Fix problem with swap component style [#9542](https://tree.taiga.io/project/penpot/issue/9542) ## 2.3.3 diff --git a/frontend/src/app/config.cljs b/frontend/src/app/config.cljs index b58876f97..b809f7e2e 100644 --- a/frontend/src/app/config.cljs +++ b/frontend/src/app/config.cljs @@ -143,6 +143,11 @@ (let [f (obj/get global "externalSessionId")] (when (fn? f) (f)))) +(defn external-context-info + [] + (let [f (obj/get global "externalContextInfo")] + (when (fn? f) (f)))) + ;; --- Helper Functions (defn ^boolean check-browser? [candidate] diff --git a/frontend/src/app/main/data/event.cljs b/frontend/src/app/main/data/event.cljs index ff5250be7..51d59b6f9 100644 --- a/frontend/src/app/main/data/event.cljs +++ b/frontend/src/app/main/data/event.cljs @@ -8,6 +8,7 @@ (:require ["ua-parser-js" :as ua] [app.common.data :as d] + [app.common.json :as json] [app.common.logging :as l] [app.config :as cf] [app.main.repo :as rp] @@ -93,6 +94,11 @@ data data)) +(defn add-external-context-info + [context] + (let [external-context-info (json/->clj (cf/external-context-info))] + (merge context external-context-info))) + (defn- process-event-by-proto [event] (let [data (d/deep-merge (-data event) (meta event)) @@ -102,6 +108,7 @@ (assoc :event-origin (::origin data)) (assoc :event-namespace (namespace type)) (assoc :event-symbol ev-name) + (add-external-context-info) (d/without-nils)) props (-> data d/without-qualified simplify-props)] @@ -119,6 +126,7 @@ (let [type (::type data "action") context (-> (::context data) (assoc :event-origin (::origin data)) + (add-external-context-info) (d/without-nils)) props (-> data d/without-qualified simplify-props)] {:type type diff --git a/frontend/src/app/main/data/workspace/thumbnails.cljs b/frontend/src/app/main/data/workspace/thumbnails.cljs index 0d2ef2239..132db9156 100644 --- a/frontend/src/app/main/data/workspace/thumbnails.cljs +++ b/frontend/src/app/main/data/workspace/thumbnails.cljs @@ -52,6 +52,11 @@ (defonce queue (q/create find-request (/ 1000 30))) +(defn clear-queue! + [] + (l/dbg :hint "clearing thumbnail queue") + (q/clear! queue)) + ;; This function first renders the HTML calling `render/render-frame` that ;; returns HTML as a string, then we send that data to the iframe rasterizer ;; that returns the image as a Blob. Finally we create a URI for that blob. diff --git a/frontend/src/app/main/data/workspace/versions.cljs b/frontend/src/app/main/data/workspace/versions.cljs index 3a8243c63..0925df03a 100644 --- a/frontend/src/app/main/data/workspace/versions.cljs +++ b/frontend/src/app/main/data/workspace/versions.cljs @@ -12,6 +12,7 @@ [app.main.data.event :as ev] [app.main.data.persistence :as dwp] [app.main.data.workspace :as dw] + [app.main.data.workspace.thumbnails :as th] [app.main.refs :as refs] [app.main.repo :as rp] [app.util.time :as dt] @@ -95,24 +96,28 @@ (assert (uuid? id) "expected valid uuid for `id`") (ptk/reify ::restore-version ptk/WatchEvent - (watch [_ state _] + (watch [_ _ _] (let [file-id (:current-file-id state)] (rx/concat (rx/of ::dwp/force-persist (dw/remove-layout-flag :document-history)) - - ;; FIXME: we should abstract this (->> (rx/from-atom refs/persistence-state {:emit-current-value? true}) (rx/filter #(or (nil? %) (= :saved %))) (rx/take 1) (rx/mapcat #(rp/cmd! :restore-file-snapshot {:file-id file-id :id id})) - (rx/map #(dw/initialize-workspace file-id))) + (rx/tap #(th/clear-queue!)) + (rx/map #(dw/initialize-file project-id file-id))) + (case origin + :version + (rx/of (ptk/event ::ev/event {::ev/name "restore-pin-version"})) - (when-let [name (case origin - :version "restore-pin-version" - :snapshot "restore-autosave" - nil)] - (rx/of (ptk/event ::ev/event {::ev/name name})))))))) + :snapshot + (rx/of (ptk/event ::ev/event {::ev/name "restore-autosave"})) + + :plugin + (rx/of (ptk/event ::ev/event {::ev/name "restore-version-plugin"})) + + (rx/empty))))))) (defn delete-version [id] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.scss b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.scss index aa443fa33..030d64cac 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.scss +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.scss @@ -402,6 +402,7 @@ .component-swap { padding-top: $s-12; + max-width: $s-248; } .component-swap-content { diff --git a/frontend/src/app/util/queue.cljs b/frontend/src/app/util/queue.cljs index 564fd3cda..4fbc72b30 100644 --- a/frontend/src/app/util/queue.cljs +++ b/frontend/src/app/util/queue.cljs @@ -9,6 +9,7 @@ (:require [app.common.logging :as l] [app.common.math :as mth] + [app.util.object :as obj] [app.util.time :as t] [beicon.v2.core :as rx])) @@ -47,13 +48,14 @@ ;; NOTE: Right now there are no cases where we need to cancel a process ;; but if we do, we can use this function -;; (defn- cancel-process -;; [queue] -;; (l/dbg :hint "queue::cancel-process") -;; (let [timeout (unchecked-get queue "timeout")] -;; (when (some? timeout) -;; (js/clearTimeout timeout)) -;; (unchecked-set queue "timeout" nil))) +(defn- cancel-process! + [queue] + (l/dbg :hint "queue::cancel-process") + (let [timeout (unchecked-get queue "timeout")] + (when (some? timeout) + (js/clearTimeout timeout)) + (unchecked-set queue "timeout" nil)) + queue) (defn- process [queue iterations] @@ -131,3 +133,10 @@ (enqueue-last queue request)))) (rx/to-observable result))) + +(defn clear! + [queue] + (-> queue + (cancel-process!) + (obj/set! "items" #js []) + (obj/set! "time" 0)))