♻️ Remove unnecessary page-id stamping on shapes

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
This commit is contained in:
Andrey Antukh 2026-07-16 11:35:30 +00:00
parent c5a29e27a6
commit b59b259a77
3 changed files with 8 additions and 11 deletions

View File

@ -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)))))

View File

@ -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])

View File

@ -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)