🐛 Fix color palette default library

This commit is contained in:
Alejandro Alonso 2024-06-05 06:38:22 +02:00
parent 3a40c7f59c
commit 697b6776ba
3 changed files with 10 additions and 3 deletions

View file

@ -149,7 +149,7 @@
shared-libs (mf/deref refs/workspace-libraries)
colors (mf/use-state [])]
(mf/with-effect [selected]
(mf/with-effect [selected shared-libs]
(let [colors' (cond
(= selected :recent) (reverse recent-colors)
(= selected :file) (->> (vals file-colors) (sort-by :name))

View file

@ -16,6 +16,7 @@
[app.common.uuid :as uuid]
[app.main.data.modal :as modal]
[app.main.data.users :as du]
[app.main.data.workspace.colors :as mdc]
[app.main.data.workspace.libraries :as dwl]
[app.main.refs :as refs]
[app.main.render :refer [component-svg]]
@ -25,6 +26,7 @@
[app.main.ui.components.search-bar :refer [search-bar]]
[app.main.ui.components.tab-container :refer [tab-container tab-element]]
[app.main.ui.components.title-bar :refer [title-bar]]
[app.main.ui.hooks :as h]
[app.main.ui.icons :as i]
[app.util.color :as uc]
[app.util.dom :as dom]
@ -113,6 +115,7 @@
components (:components library)
media (:media library)
typographies (:typographies library)
selected (h/use-shared-state mdc/colorpalette-selected-broadcast-key :recent)
empty-library? (and
(zero? (count colors))
@ -146,6 +149,7 @@
(let [library-id (some-> (dom/get-current-target event)
(dom/get-data "library-id")
(parse-uuid))]
(reset! selected library-id)
(st/emit! (dwl/link-file-to-library file-id library-id)))))
unlink-library
@ -155,6 +159,8 @@
(let [library-id (some-> (dom/get-current-target event)
(dom/get-data "library-id")
(parse-uuid))]
(when (= library-id @selected)
(reset! selected :file))
(st/emit! (dwl/unlink-file-from-library file-id library-id)
(dwl/sync-file file-id library-id)))))