From b59b259a773aa2f1ab81e739b83d5ae0f59e7030 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 16 Jul 2026 11:35:30 +0000 Subject: [PATCH] :recycle: Remove unnecessary page-id stamping on shapes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stop stamping :page-id onto shape objects in three places: - files_thumbnails.clj: get-thumbnail-frame now returns [frame page-id] pair instead of stamping the page-id onto the frame itself - binfile/v3.clj: remove stamp on export (import derives page-id from zip entry path, never reads it from the shape) - library/export.cljs: same — remove stamp on library export The page-id is always available from context in these code paths. AI-assisted-by: deepseek-v4-pro --- backend/src/app/binfile/v3.clj | 1 - backend/src/app/rpc/commands/files_thumbnails.clj | 13 ++++++------- library/src/lib/export.cljs | 5 ++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/backend/src/app/binfile/v3.clj b/backend/src/app/binfile/v3.clj index 952cb69e8f..311cbc96aa 100644 --- a/backend/src/app/binfile/v3.clj +++ b/backend/src/app/binfile/v3.clj @@ -316,7 +316,6 @@ (doseq [[shape-id shape] objects] (let [path (str "files/" file-id "/pages/" page-id "/" shape-id ".json") - shape (assoc shape :page-id page-id) shape (encode-shape shape)] (write-entry! output path shape))))) diff --git a/backend/src/app/rpc/commands/files_thumbnails.clj b/backend/src/app/rpc/commands/files_thumbnails.clj index 024bce17e7..8aaa98cbdd 100644 --- a/backend/src/app/rpc/commands/files_thumbnails.clj +++ b/backend/src/app/rpc/commands/files_thumbnails.clj @@ -98,14 +98,13 @@ (defn get-file-data-for-thumbnail [{:keys [::db/conn] :as cfg} {:keys [data id] :as file} strip-frames-with-thumbnails] (letfn [;; function responsible on finding the frame marked to be - ;; used as thumbnail; the returned frame always have - ;; the :page-id set to the page that it belongs. + ;; used as thumbnail; returns a [frame page-id] pair. (get-thumbnail-frame [{:keys [data]}] - (d/seek #(or (:use-for-thumbnail %) - (:use-for-thumbnail? %)) ; NOTE: backward comp (remove on v1.21) + (d/seek (fn [[frame]] (or (:use-for-thumbnail frame) + (:use-for-thumbnail? frame))) ; NOTE: backward comp (remove on v1.21) (for [page (-> data :pages-index vals) frame (-> page :objects ctt/get-frames)] - (assoc frame :page-id (:id page))))) + [frame (:id page)]))) ;; function responsible to filter objects data structure of ;; all unneeded shapes if a concrete frame is provided. If no @@ -152,9 +151,9 @@ objects)))] - (let [frame (get-thumbnail-frame file) + (let [[frame page-id] (get-thumbnail-frame file) frame-id (:id frame) - page-id (or (:page-id frame) + page-id (or page-id (-> data :pages first)) page (dm/get-in data [:pages-index page-id]) diff --git a/library/src/lib/export.cljs b/library/src/lib/export.cljs index 7ce561fa12..024e4e0d92 100644 --- a/library/src/lib/export.cljs +++ b/library/src/lib/export.cljs @@ -118,9 +118,8 @@ [(str "files/" id "/pages/" page-id ".json") (delay (-> page encode-page json/encode))] (map (fn [[shape-id shape]] - (let [shape (assoc shape :page-id page-id)] - [(str "files/" id "/pages/" page-id "/" shape-id ".json") - (delay (encode-shape* shape))])) + [(str "files/" id "/pages/" page-id "/" shape-id ".json") + (delay (encode-shape* shape))]) objects))))))) (->> (get data :components)