Skip to content

Commit

Permalink
Merge pull request #2357 from sid597/remove-context-menu-for-inbox
Browse files Browse the repository at this point in the history
remove context menu options for inbox
  • Loading branch information
filipesilva authored Sep 9, 2022
2 parents d7274a9 + efd0768 commit 86682a3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 53 deletions.
12 changes: 0 additions & 12 deletions src/cljs/athens/views/blocks/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
BreadcrumbItem
BreadcrumbLink
Button
Divider
HStack
MenuDivider
MenuGroup
Expand Down Expand Up @@ -437,17 +436,6 @@
[:<>
[:> MenuDivider]
[block-reaction/reactions-menu-list uid user-id]])

(when (and notifications-enabled? (actions/is-block-inbox? properties))
[:<>
[:> Divider]
[:> MenuItem {:children "Archive all notifications"
:icon (r/as-element [:> ArchiveIcon])
:onClick #(actions/archive-all-notifications uid)}]
[:> MenuItem {:children "Unarchive all notifications"
:icon (r/as-element [:> ArchiveIcon])
:onClick #(actions/unarchive-all-notifications uid)}]])

(when (and notifications-enabled? (actions/is-block-notification? properties))
[:> MenuItem {:children "Archive"
:icon (r/as-element [:> ArchiveIcon])
Expand Down
42 changes: 1 addition & 41 deletions src/cljs/athens/views/notifications/actions.cljs
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
(ns athens.views.notifications.actions
(:require
[athens.common-db :as common-db]
[athens.common-events :as common-events]
[athens.common-events.graph.composite :as composite-ops]
[athens.common-events.graph.ops :as graph-ops]
[athens.db :as db]
[re-frame.core :as rf]))


(defn is-block-inbox?
[properties]
(= "athens/inbox"
(:block/string (get properties ":entity/type"))))
[athens.db :as db]))


(defn is-block-notification?
Expand Down Expand Up @@ -61,34 +52,3 @@
(fn [db prop-uid]
[(graph-ops/build-block-save-op db prop-uid new-state)])])]
updated-prop))


(defn multi-uids-prop-update
[uids key new-val]
(let [ops (into [] (map
#(let [[prop-uid] (graph-ops/build-path @db/dsdb % [key])
save-op (graph-ops/build-block-save-op @db/dsdb prop-uid new-val)]
save-op)
uids))
composite-op (composite-ops/make-consequence-op {:op/type :show-hidden-notifications}
ops)
event (common-events/build-atomic-event composite-op)]
(rf/dispatch [:resolve-transact-forward event])))


(defn unarchive-all-notifications
[inbox-uid]
(let [all-notifications (->> (common-db/get-block-document @db/dsdb [:block/uid inbox-uid])
:block/children
(mapv :block/uid))]
(multi-uids-prop-update all-notifications "athens/notification/is-archived" "false")))


(defn archive-all-notifications
[inbox-uid]
(let [all-notifications (->> (common-db/get-block-document @db/dsdb [:block/uid inbox-uid])
:block/children
(mapv :block/uid))]
(multi-uids-prop-update all-notifications "athens/notification/is-archived" "true")))


0 comments on commit 86682a3

Please sign in to comment.