diff --git a/backend/src/app/rpc/commands/files.clj b/backend/src/app/rpc/commands/files.clj index 8dd1e0a55..054bf22ff 100644 --- a/backend/src/app/rpc/commands/files.clj +++ b/backend/src/app/rpc/commands/files.clj @@ -241,7 +241,6 @@ [conn id client-features] ;; here we check if client requested features are supported (check-features-compatibility! client-features) - (binding [pmap/*load-fn* (partial load-pointer conn id)] (-> (db/get-by-id conn :file id) (decode-row) @@ -533,12 +532,14 @@ [conn file-id client-features] (check-features-compatibility! client-features) (->> (db/exec! conn [sql:file-libraries file-id]) - (mapv (fn [{:keys [id] :as row}] - (binding [pmap/*load-fn* (partial load-pointer conn id)] - (-> (decode-row row) - (assoc :is-indirect false) - (update :data dissoc :pages-index) - (handle-file-features client-features))))))) + (map decode-row) + (map #(assoc % :is-indirect false)) + (map (fn [{:keys [id] :as row}] + (binding [pmap/*load-fn* (partial load-pointer conn id)] + (-> row + (update :data dissoc :pages-index) + (handle-file-features client-features))))) + (vec))) (s/def ::get-file-libraries (s/keys :req [::rpc/profile-id] @@ -708,28 +709,30 @@ objects)))] - (let [frame (get-thumbnail-frame data) - frame-id (:id frame) - page-id (or (:page-id frame) - (-> data :pages first)) + (binding [pmap/*load-fn* (partial load-pointer conn id)] + (let [frame (get-thumbnail-frame data) + frame-id (:id frame) + page-id (or (:page-id frame) + (-> data :pages first)) - page (dm/get-in data [:pages-index page-id]) - frame-ids (if (some? frame) (list frame-id) (map :id (ctt/get-frames (:objects page)))) + page (dm/get-in data [:pages-index page-id]) + page (cond-> page (pmap/pointer-map? page) deref) + frame-ids (if (some? frame) (list frame-id) (map :id (ctt/get-frames (:objects page)))) - obj-ids (map #(str page-id %) frame-ids) - thumbs (get-object-thumbnails conn id obj-ids)] + obj-ids (map #(str page-id %) frame-ids) + thumbs (get-object-thumbnails conn id obj-ids)] - (cond-> page - ;; If we have frame, we need to specify it on the page level - ;; and remove the all other unrelated objects. - (some? frame-id) - (-> (assoc :thumbnail-frame-id frame-id) - (update :objects filter-objects frame-id)) + (cond-> page + ;; If we have frame, we need to specify it on the page level + ;; and remove the all other unrelated objects. + (some? frame-id) + (-> (assoc :thumbnail-frame-id frame-id) + (update :objects filter-objects frame-id)) - ;; Assoc the available thumbnails and prune not visible shapes - ;; for avoid transfer unnecessary data. - :always - (update :objects assoc-thumbnails page-id thumbs))))) + ;; Assoc the available thumbnails and prune not visible shapes + ;; for avoid transfer unnecessary data. + :always + (update :objects assoc-thumbnails page-id thumbs)))))) (s/def ::get-file-data-for-thumbnail (s/keys :req [::rpc/profile-id] @@ -743,12 +746,15 @@ [{:keys [pool] :as cfg} {:keys [::rpc/profile-id file-id features] :as props}] (with-open [conn (db/open pool)] (check-read-permissions! conn profile-id file-id) - (let [file (get-file conn file-id features)] + ;; NOTE: we force here the "storage/pointer-map" feature, because + ;; it used internally only and is independent if user supports it + ;; or not. + (let [feat (into #{"storage/pointer-map"} features) + file (get-file conn file-id feat)] {:file-id file-id :revn (:revn file) :page (get-file-data-for-thumbnail conn file)}))) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; MUTATION COMMANDS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index e6517f329..55d98260c 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -150,14 +150,15 @@ (defn- bundle-fetched [features [{:keys [id data] :as file} thumbnails project users comments-users]] - (letfn [(resolve-pointer [[key pointer]] - (->> (rp/cmd! :get-file-fragment {:file-id id :fragment-id @pointer}) + (letfn [(resolve-pointer [file-id [key pointer]] + (->> (rp/cmd! :get-file-fragment {:file-id file-id :fragment-id @pointer}) (rx/map :content) (rx/map #(vector key %)))) - (resolve-pointers [in-to coll] + + (resolve-pointers [file-id coll] (->> (rx/from (seq coll)) - (rx/merge-map resolve-pointer) - (rx/reduce conj in-to)))] + (rx/merge-map (partial resolve-pointer file-id)) + (rx/reduce conj {})))] (ptk/reify ::bundle-fetched ptk/UpdateEvent @@ -186,7 +187,7 @@ (rx/merge-map (fn [[_ page :as kp]] (if (t/pointer? page) - (resolve-pointer kp) + (resolve-pointer id kp) (rx/of kp)))) (rx/merge-map (fn [[id page]] @@ -212,15 +213,17 @@ (->> data (filter (comp t/pointer? val)) - (resolve-pointers {}) + (resolve-pointers id) (rx/map workspace-data-pointers-loaded)) (->> (rp/cmd! :get-file-libraries {:file-id id :features features}) (rx/mapcat identity) (rx/mapcat - (fn [file] - (->> (filter (comp t/pointer? val) file) - (resolve-pointers file)))) + (fn [{:keys [id data] :as file}] + (->> (filter (comp t/pointer? val) data) + (resolve-pointers id) + (rx/map #(update file :data merge %))))) + (rx/reduce conj []) (rx/map libraries-fetched))))))) (rx/take-until stoper))))))) diff --git a/frontend/src/app/main/repo.cljs b/frontend/src/app/main/repo.cljs index 2fa651daf..55c2e3976 100644 --- a/frontend/src/app/main/repo.cljs +++ b/frontend/src/app/main/repo.cljs @@ -22,6 +22,7 @@ (derive :get-team-members ::query) (derive :get-team-stats ::query) (derive :get-team-invitations ::query) +(derive :get-team-shared-files ::query) (defn handle-response [{:keys [status body] :as response}]