0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-12 15:51:37 -05:00

🔥 Remove unused d/update-vals function

Already available as clojure.core/update-vals
This commit is contained in:
Andrey Antukh 2022-11-21 15:59:25 +01:00 committed by Andrés Moya
parent ccb7c466bf
commit 1b9dea01e2
9 changed files with 42 additions and 51 deletions

View file

@ -409,7 +409,7 @@
"Given the page data, removes the `:thumbnail` prop from all "Given the page data, removes the `:thumbnail` prop from all
shapes." shapes."
[page] [page]
(update page :objects d/update-vals #(dissoc % :thumbnail))) (update page :objects update-vals #(dissoc % :thumbnail)))
(defn get-page (defn get-page
[conn {:keys [file-id page-id object-id features]}] [conn {:keys [file-id page-id object-id features]}]

View file

@ -232,13 +232,6 @@
([mfn coll] ([mfn coll]
(into {} (mapm mfn) coll))) (into {} (mapm mfn) coll)))
(defn update-vals
"m f => {k (f v) ...}
Given a map m and a function f of 1-argument, returns a new map where the keys of m
are mapped to result of applying f to the corresponding values of m."
[m f]
(c/update-vals m f))
(defn removev (defn removev
"Returns a vector of the items in coll for which (fn item) returns logical false" "Returns a vector of the items in coll for which (fn item) returns logical false"
[fn coll] [fn coll]

View file

@ -411,7 +411,7 @@
cur (-> (or (get objects frame-id) (transient {})) cur (-> (or (get objects frame-id) (transient {}))
(assoc! id shape))] (assoc! id shape))]
(assoc! objects frame-id cur)))] (assoc! objects frame-id cur)))]
(d/update-vals (update-vals
(->> objects (->> objects
(reduce process-shape (transient {})) (reduce process-shape (transient {}))
(persistent!)) (persistent!))
@ -432,7 +432,7 @@
(update shape :shapes #(filterv selected+parents %)))] (update shape :shapes #(filterv selected+parents %)))]
(-> (select-keys objects selected+parents) (-> (select-keys objects selected+parents)
(d/update-vals remove-children)))) (update-vals remove-children))))
(defn is-child? (defn is-child?
[objects parent-id candidate-child-id] [objects parent-id candidate-child-id]

View file

@ -6,7 +6,6 @@
(ns app.common.pages.indices (ns app.common.pages.indices
(:require (:require
[app.common.data :as d]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.uuid :as uuid])) [app.common.uuid :as uuid]))
@ -54,4 +53,4 @@
(mapcat get-clip-parents)) (mapcat get-clip-parents))
parents)))] parents)))]
(-> parents-index (-> parents-index
(d/update-vals retrieve-clips)))) (update-vals retrieve-clips))))

View file

@ -54,9 +54,9 @@
(into [] shapes) (into [] shapes)
shapes)))) shapes))))
(update-page [page] (update-page [page]
(update page :objects d/update-vals update-object))] (update page :objects update-vals update-object))]
(update data :pages-index d/update-vals update-page))) (update data :pages-index update-vals update-page)))
;; Changes paths formats ;; Changes paths formats
(defmethod migrate 3 (defmethod migrate 3
@ -105,9 +105,9 @@
(fix-empty-points))) (fix-empty-points)))
(update-page [page] (update-page [page]
(update page :objects d/update-vals update-object))] (update page :objects update-vals update-object))]
(update data :pages-index d/update-vals update-page))) (update data :pages-index update-vals update-page)))
;; We did rollback version 4 migration. ;; We did rollback version 4 migration.
;; Keep this in order to remember the next version to be 5 ;; Keep this in order to remember the next version to be 5
@ -123,9 +123,9 @@
object)) object))
(update-page [page] (update-page [page]
(update page :objects d/update-vals update-object))] (update page :objects update-vals update-object))]
(update data :pages-index d/update-vals update-page))) (update data :pages-index update-vals update-page)))
(defmethod migrate 6 (defmethod migrate 6
[data] [data]
@ -147,11 +147,11 @@
shape)) shape))
(update-container [container] (update-container [container]
(update container :objects d/update-vals fix-line-paths))] (update container :objects update-vals fix-line-paths))]
(-> data (-> data
(update :pages-index d/update-vals update-container) (update :pages-index update-vals update-container)
(update :components d/update-vals update-container)))) (update :components update-vals update-container))))
;; Remove interactions pointing to deleted frames ;; Remove interactions pointing to deleted frames
(defmethod migrate 7 (defmethod migrate 7
@ -162,9 +162,9 @@
(filterv #(get-in page [:objects (:destination %)]) interactions)))) (filterv #(get-in page [:objects (:destination %)]) interactions))))
(update-page [page] (update-page [page]
(update page :objects d/update-vals (partial update-object page)))] (update page :objects update-vals (partial update-object page)))]
(update data :pages-index d/update-vals update-page))) (update data :pages-index update-vals update-page)))
;; Remove groups without any shape, both in pages and components ;; Remove groups without any shape, both in pages and components
@ -205,8 +205,8 @@
(assoc container :objects objects)))))] (assoc container :objects objects)))))]
(-> data (-> data
(update :pages-index d/update-vals clean-container) (update :pages-index update-vals clean-container)
(update :components d/update-vals clean-container)))) (update :components update-vals clean-container))))
(defmethod migrate 9 (defmethod migrate 9
[data] [data]
@ -240,7 +240,7 @@
[data] [data]
(letfn [(update-page [page] (letfn [(update-page [page]
(d/update-in-when page [:objects uuid/zero] dissoc :points :selrect))] (d/update-in-when page [:objects uuid/zero] dissoc :points :selrect))]
(update data :pages-index d/update-vals update-page))) (update data :pages-index update-vals update-page)))
(defmethod migrate 11 (defmethod migrate 11
[data] [data]
@ -252,9 +252,9 @@
(update-page [page] (update-page [page]
(update page :objects (fn [objects] (update page :objects (fn [objects]
(d/update-vals objects (partial update-object objects)))))] (update-vals objects (partial update-object objects)))))]
(update data :pages-index d/update-vals update-page))) (update data :pages-index update-vals update-page)))
(defmethod migrate 12 (defmethod migrate 12
[data] [data]
@ -264,9 +264,9 @@
(assoc :size nil))) (assoc :size nil)))
(update-page [page] (update-page [page]
(d/update-in-when page [:options :saved-grids] d/update-vals update-grid))] (d/update-in-when page [:options :saved-grids] update-vals update-grid))]
(update data :pages-index d/update-vals update-page))) (update data :pages-index update-vals update-page)))
;; Add rx and ry to images ;; Add rx and ry to images
(defmethod migrate 13 (defmethod migrate 13
@ -284,9 +284,9 @@
(fix-radius))) (fix-radius)))
(update-page [page] (update-page [page]
(update page :objects d/update-vals update-object))] (update page :objects update-vals update-object))]
(update data :pages-index d/update-vals update-page))) (update data :pages-index update-vals update-page)))
(defmethod migrate 14 (defmethod migrate 14
[data] [data]
@ -314,8 +314,8 @@
(assoc container :objects objects))))] (assoc container :objects objects))))]
(-> data (-> data
(update :pages-index d/update-vals update-container) (update :pages-index update-vals update-container)
(update :components d/update-vals update-container)))) (update :components update-vals update-container))))
(defmethod migrate 15 [data] data) (defmethod migrate 15 [data] data)
@ -361,11 +361,11 @@
(assign-fills))) (assign-fills)))
(update-container [container] (update-container [container]
(update container :objects d/update-vals update-object))] (update container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index d/update-vals update-container) (update :pages-index update-vals update-container)
(update :components d/update-vals update-container)))) (update :components update-vals update-container))))
(defmethod migrate 17 (defmethod migrate 17
[data] [data]
@ -390,11 +390,11 @@
(assoc :fills []))) (assoc :fills [])))
(update-container [container] (update-container [container]
(update container :objects d/update-vals update-object))] (update container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index d/update-vals update-container) (update :pages-index update-vals update-container)
(update :components d/update-vals update-container)))) (update :components update-vals update-container))))
;;Remove position-data to solve a bug with the text positioning ;;Remove position-data to solve a bug with the text positioning
(defmethod migrate 18 (defmethod migrate 18
@ -405,11 +405,11 @@
(dissoc :position-data))) (dissoc :position-data)))
(update-container [container] (update-container [container]
(update container :objects d/update-vals update-object))] (update container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index d/update-vals update-container) (update :pages-index update-vals update-container)
(update :components d/update-vals update-container)))) (update :components update-vals update-container))))
(defmethod migrate 19 (defmethod migrate 19
[data] [data]
@ -421,11 +421,11 @@
(dissoc :position-data))) (dissoc :position-data)))
(update-container [container] (update-container [container]
(update container :objects d/update-vals update-object))] (update container :objects update-vals update-object))]
(-> data (-> data
(update :pages-index d/update-vals update-container) (update :pages-index update-vals update-container)
(update :components d/update-vals update-container)))) (update :components update-vals update-container))))
;; TODO: pending to do a migration for delete already not used fill ;; TODO: pending to do a migration for delete already not used fill
;; and stroke props. This should be done for >1.14.x version. ;; and stroke props. This should be done for >1.14.x version.

View file

@ -6,7 +6,6 @@
(ns app.main.data.workspace.persistence (ns app.main.data.workspace.persistence
(:require (:require
[app.common.data :as d]
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.logging :as log] [app.common.logging :as log]
[app.common.pages :as cp] [app.common.pages :as cp]
@ -156,7 +155,7 @@
frame-updates frame-updates
(-> (group-by :page-id changes) (-> (group-by :page-id changes)
(d/update-vals #(into #{} (mapcat :frames) %)))] (update-vals #(into #{} (mapcat :frames) %)))]
(rx/merge (rx/merge
(->> (rx/from frame-updates) (->> (rx/from frame-updates)

View file

@ -132,7 +132,7 @@
children-ids (cph/get-children-ids objects parent-id) children-ids (cph/get-children-ids objects parent-id)
children children
(-> (select-keys objects children-ids) (-> (select-keys objects children-ids)
(d/update-vals (update-vals
(fn [child] (fn [child]
(cond-> child (cond-> child
(contains? modifiers (:id child)) (contains? modifiers (:id child))

View file

@ -242,7 +242,7 @@
text-shapes text-shapes
(mf/use-memo (mf/use-memo
(mf/deps text-shapes modifiers) (mf/deps text-shapes modifiers)
#(d/update-vals text-shapes (partial process-shape modifiers))) #(update-vals text-shapes (partial process-shape modifiers)))
editing-shape (get text-shapes edition) editing-shape (get text-shapes edition)

View file

@ -350,7 +350,7 @@
(mapv #(update % :starting-frame resolve))) (mapv #(update % :starting-frame resolve)))
guides (-> (get-in page-data [:options :guides]) guides (-> (get-in page-data [:options :guides])
(d/update-vals #(update % :frame-id resolve))) (update-vals #(update % :frame-id resolve)))
page-data (-> page-data page-data (-> page-data
(d/assoc-in-when [:options :flows] flows) (d/assoc-in-when [:options :flows] flows)