Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove context menu options for inbox #2357

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")))