From f4a0b304a972374c6795d100a79c4dde75743b83 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Mon, 24 Oct 2022 16:26:49 +0200 Subject: [PATCH] :bug: Fix displaying comments settings are not applied via "Comments" menu drop-down on the top navbar on view mode --- CHANGES.md | 1 + frontend/src/app/main/ui/viewer/comments.cljs | 48 +++++++++---------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 10a3b0319..301fc7d29 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ - Fix transform to path RMB menu item is not relevant if shape is already path [Taiga #4302](https://tree.taiga.io/project/penpot/issue/4302) - Fix join nodes icon is active when 2 already joined nodes are selected [Taiga #4370](https://tree.taiga.io/project/penpot/issue/4370) - Fix path nodes panel. "To curve" and "To corner" icons are active if node is already curved/cornered [Taiga #4371](https://tree.taiga.io/project/penpot/issue/4371) +- Fix displaying comments settings are not applied via "Comments" menu drop-down on the top navbar on view mode [Taiga #4389](https://tree.taiga.io/project/penpot/issue/4389) ## 1.16.0-beta diff --git a/frontend/src/app/main/ui/viewer/comments.cljs b/frontend/src/app/main/ui/viewer/comments.cljs index b0fe50432..116b5dcce 100644 --- a/frontend/src/app/main/ui/viewer/comments.cljs +++ b/frontend/src/app/main/ui/viewer/comments.cljs @@ -6,7 +6,6 @@ (ns app.main.ui.viewer.comments (:require - [app.common.data :as d] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] @@ -27,21 +26,26 @@ {::mf/wrap [mf/memo] ::mf/wrap-props false} [] - (let [local (mf/deref refs/comments-local) - owner-filter (:owner-filter local) - status-filter (:status-filter local) - show-sidebar? (:show-sidebar? local) + (let [{cmode :mode cshow :show show-sidebar? :show-sidebar?} (mf/deref refs/comments-local) show-dropdown? (mf/use-state false) toggle-dropdown (mf/use-fn #(swap! show-dropdown? not)) hide-dropdown (mf/use-fn #(reset! show-dropdown? false)) - update-option (mf/use-fn - (fn [event] - (let [target (dom/get-current-target event) - key (d/read-string (dom/get-attribute target "data-key")) - val (d/read-string (dom/get-attribute target "data-val"))] - (st/emit! (dcm/update-options {key val})))))] + update-mode + (mf/use-callback + (fn [mode] + (st/emit! (dcm/update-filters {:mode mode})))) + + update-show + (mf/use-callback + (fn [mode] + (st/emit! (dcm/update-filters {:show mode})))) + + update-options + (mf/use-callback + (fn [mode] + (st/emit! (dcm/update-options {:show-sidebar? mode}))))] [:div.view-options {:on-click toggle-dropdown} [:span.label (tr "labels.comments")] @@ -50,34 +54,26 @@ :on-close hide-dropdown} [:ul.dropdown.with-check - [:li {:class (dom/classnames :selected (= :all owner-filter)) - :data-key ":owner-filter" - :data-val ":all" - :on-click update-option} + [:li {:class (dom/classnames :selected (or (= :all cmode) (nil? cmode))) + :on-click #(update-mode :all)} [:span.icon i/tick] [:span.label (tr "labels.show-all-comments")]] - [:li {:class (dom/classnames :selected (= :yours owner-filter)) - :data-key ":owner-filter" - :data-val ":yours" - :on-click update-option} + [:li {:class (dom/classnames :selected (= :yours cmode)) + :on-click #(update-mode :yours)} [:span.icon i/tick] [:span.label (tr "labels.show-your-comments")]] [:hr] - [:li {:class (dom/classnames :selected (= :pending status-filter)) - :data-key ":status-filter" - :data-val (if (= :pending status-filter) ":all" ":pending") - :on-click update-option} + [:li {:class (dom/classnames :selected (= :pending cshow)) + :on-click #(update-show (if (= :pending cshow) :all :pending))} [:span.icon i/tick] [:span.label (tr "labels.hide-resolved-comments")]] [:hr] [:li {:class (dom/classnames :selected show-sidebar?) - :data-key ":show-sidebar?" - :data-val (if show-sidebar? "false" "true") - :on-click update-option} + :on-click #(update-options (not show-sidebar?))} [:span.icon i/tick] [:span.label (tr "labels.show-comments-list")]]]]]))