mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
✨ Mark all notifications as read from dashboard (#5805)
* ✨ Mark all notifications as read from dashboard * ♻️ Mark all notifications as read code review * ♻️ Mark all notifications as read code review II
This commit is contained in:
parent
8a332c1402
commit
59a57d6c3f
6 changed files with 64 additions and 2 deletions
|
@ -14,8 +14,10 @@
|
|||
[app.common.uuid :as uuid]
|
||||
[app.main.data.event :as ev]
|
||||
[app.main.data.helpers :as dsh]
|
||||
[app.main.data.notifications :as ntf]
|
||||
[app.main.data.team :as dtm]
|
||||
[app.main.repo :as rp]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[beicon.v2.core :as rx]
|
||||
[potok.v2.core :as ptk]))
|
||||
|
||||
|
@ -454,6 +456,26 @@
|
|||
(rx/map #(partial fetched-users %))))))
|
||||
(rx/catch #(rx/throw {:type :comment-error})))))))
|
||||
|
||||
(defn mark-all-threads-as-read
|
||||
"Mark all threads as read"
|
||||
[team-id]
|
||||
(ptk/reify ::mark-all-threads-as-read
|
||||
ev/Event
|
||||
(-data [_] {})
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [threads (-> state :comment-threads vals)]
|
||||
(rx/concat
|
||||
(->> (rp/cmd! :mark-all-threads-as-read {:threads (mapv :id threads)})
|
||||
(rx/map #(retrieve-unread-comment-threads team-id))
|
||||
(rx/catch #(rx/throw {:type :comment-error})))
|
||||
(rx/of (ntf/show {:level :info
|
||||
:type :toast
|
||||
:content (tr "dashboard.mark-all-as-read.success")
|
||||
:timeout 7000})))))))
|
||||
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Local State
|
||||
|
|
|
@ -63,7 +63,13 @@
|
|||
(mf/use-callback
|
||||
(fn [thread]
|
||||
(st/emit! (-> (dwcm/navigate thread)
|
||||
(with-meta {::ev/origin "dashboard"})))))]
|
||||
(with-meta {::ev/origin "dashboard"})))))
|
||||
|
||||
on-read-all
|
||||
(mf/use-callback
|
||||
(mf/deps team-id)
|
||||
(fn []
|
||||
(st/emit! (dcm/mark-all-threads-as-read team-id))))]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps team-id)
|
||||
|
@ -82,6 +88,13 @@
|
|||
[:div {:class (stl/css :dropdown :comments-section :comment-threads-section)}
|
||||
[:div {:class (stl/css :header)}
|
||||
[:h3 {:class (stl/css :header-title)} (tr "dashboard.notifications")]
|
||||
(when (seq tgroups)
|
||||
[:> icon-button* {:variant "ghost"
|
||||
:tab-index (if show? "0" "-1")
|
||||
:aria-label (tr "label.mark-all-as-read")
|
||||
:on-click on-read-all
|
||||
:icon "tick"}])
|
||||
|
||||
[:> icon-button* {:variant "ghost"
|
||||
:tab-index (if show? "0" "-1")
|
||||
:aria-label (tr "labels.close")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue