0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-11 01:28:30 -05:00

🐛 Fix list view is discarded on tab change for assets sidebar

This commit is contained in:
Alejandro Alonso 2023-08-31 09:58:04 +02:00
parent da3c829b1b
commit 50932dea54
4 changed files with 53 additions and 5 deletions

View file

@ -1,5 +1,11 @@
# CHANGELOG
## 1.19.3
### :bug: Bugs fixed
- List view is discarded on tab change on Workspace Assets Sidebar tab [Github #3547](https://github.com/penpot/penpot/issues/3547)
## 1.19.2
### :sparkles: New features

View file

@ -0,0 +1,28 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns app.main.data.workspace.assets
"Workspace assets management events and helpers."
(:require
[app.util.storage :refer [storage]]))
(defn get-current-assets-ordering
[]
(let [ordering (::ordering @storage)]
(or ordering :asc)))
(defn set-current-assets-ordering!
[ordering]
(swap! storage assoc ::ordering ordering))
(defn get-current-assets-list-style
[]
(let [list-style (::list-style @storage)]
(or list-style :thumbs)))
(defn set-current-assets-list-style!
[list-style]
(swap! storage assoc ::list-style list-style))

View file

@ -16,6 +16,7 @@
[app.main.data.events :as ev]
[app.main.data.modal :as modal]
[app.main.data.workspace :as dw]
[app.main.data.workspace.assets :as dwa]
[app.main.data.workspace.colors :as dc]
[app.main.data.workspace.libraries :as dwl]
[app.main.data.workspace.media :as dwm]
@ -2424,19 +2425,32 @@
[]
(let [components-v2 (mf/use-ctx ctx/components-v2)
read-only? (mf/use-ctx ctx/workspace-read-only?)
filters* (mf/use-state
{:term ""
:section :all
:ordering :asc
:list-style :thumbs})
:ordering (dwa/get-current-assets-ordering)
:list-style (dwa/get-current-assets-list-style)})
filters (deref filters*)
term (:term filters)
ordering (:ordering filters)
list-style (:list-style filters)
toggle-ordering
(mf/use-fn #(swap! filters* update :ordering toggle-values [:asc :desc]))
(mf/use-fn
(mf/deps ordering)
(fn []
(let [new-value (toggle-values ordering [:asc :desc])]
(swap! filters* assoc :ordering new-value)
(dwa/set-current-assets-ordering! new-value))))
toggle-list-style
(mf/use-fn #(swap! filters* update :list-style toggle-values [:thumbs :list]))
(mf/use-fn
(mf/deps list-style)
(fn []
(let [new-value (toggle-values list-style [:thumbs :list])]
(swap! filters* assoc :list-style new-value)
(dwa/set-current-assets-list-style! new-value))))
on-search-term-change
(mf/use-fn

View file

@ -1 +1 @@
1.19.2
1.19.3