From c892a9f2543d683cc0860c86524641d90240ea06 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 25 Sep 2025 09:42:57 +0200 Subject: [PATCH] :sparkles: Integrate objects-map usage on backend and frontend --- backend/src/app/features/fdata.clj | 11 +++++------ backend/src/app/rpc/commands/files.clj | 26 ++++++++++++++++++-------- frontend/src/app/main.cljs | 1 + frontend/src/app/worker.cljs | 1 + 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/backend/src/app/features/fdata.clj b/backend/src/app/features/fdata.clj index c59cdd0ca4..43cf612068 100644 --- a/backend/src/app/features/fdata.clj +++ b/backend/src/app/features/fdata.clj @@ -12,12 +12,13 @@ [app.common.files.helpers :as cfh] [app.common.files.migrations :as fmg] [app.common.logging :as l] + [app.common.types.objects-map :as omap] [app.common.types.path :as path] [app.db :as db] [app.db.sql :as-alias sql] [app.storage :as sto] [app.util.blob :as blob] - [app.util.objects-map :as omap] + [app.util.objects-map :as omap.legacy] [app.util.pointer-map :as pmap] [app.worker :as wrk] [promesa.exec :as px])) @@ -38,10 +39,7 @@ [file & _opts] (let [update-page (fn [page] - (if (and (pmap/pointer-map? page) - (not (pmap/loaded? page))) - page - (update page :objects omap/wrap))) + (update page :objects omap/wrap)) update-data (fn [fdata] @@ -60,7 +58,8 @@ (fn [page] (update page :objects (fn [objects] - (if (omap/objects-map? objects) + (if (or (omap/objects-map? objects) + (omap.legacy/objects-map? objects)) (update-fn objects) objects))))) fdata)) diff --git a/backend/src/app/rpc/commands/files.clj b/backend/src/app/rpc/commands/files.clj index 4b4149603f..91a4947608 100644 --- a/backend/src/app/rpc/commands/files.clj +++ b/backend/src/app/rpc/commands/files.clj @@ -342,14 +342,24 @@ (cfeat/check-client-features! (:features params)) (cfeat/check-file-features! (:features file))) - ;; This operation is needed for backward comapatibility with frontends that - ;; does not support pointer-map resolution mechanism; this just resolves the - ;; pointers on backend and return a complete file. - (if (and (contains? (:features file) "fdata/pointer-map") - (not (contains? (:features params) "fdata/pointer-map"))) - (binding [pmap/*load-fn* (partial feat.fdata/load-pointer cfg id)] - (update file :data feat.fdata/process-pointers deref)) - file)))) + (as-> file file + ;; This operation is needed for backward comapatibility with + ;; frontends that does not support pointer-map resolution + ;; mechanism; this just resolves the pointers on backend and + ;; return a complete file + (if (and (contains? (:features file) "fdata/pointer-map") + (not (contains? (:features params) "fdata/pointer-map"))) + (binding [pmap/*load-fn* (partial feat.fdata/load-pointer cfg id)] + (update file :data feat.fdata/process-pointers deref)) + file) + + ;; This operation is needed for backward comapatibility with + ;; frontends that does not support objects-map mechanism; this + ;; just converts all objects map instaces to plain maps + (if (and (contains? (:features file) "fdata/objects-map") + (not (contains? (:features params) "fdata/objects-map"))) + (update file :data feat.fdata/process-objects (partial into {})) + file))))) ;; --- COMMAND QUERY: get-file-fragment (by id) diff --git a/frontend/src/app/main.cljs b/frontend/src/app/main.cljs index ee08002475..06fde42430 100644 --- a/frontend/src/app/main.cljs +++ b/frontend/src/app/main.cljs @@ -8,6 +8,7 @@ (:require [app.common.data.macros :as dm] [app.common.logging :as log] + [app.common.types.objects-map] [app.common.uuid :as uuid] [app.config :as cf] [app.main.data.auth :as da] diff --git a/frontend/src/app/worker.cljs b/frontend/src/app/worker.cljs index dce2f952d1..d5d5f18e44 100644 --- a/frontend/src/app/worker.cljs +++ b/frontend/src/app/worker.cljs @@ -9,6 +9,7 @@ [app.common.data.macros :as dm] [app.common.logging :as log] [app.common.schema :as sm] + [app.common.types.objects-map] [app.util.object :as obj] [app.worker.export] [app.worker.impl :as impl]