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

Fix bugs in comments #2285

Merged
merged 6 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion src/cljs/athens/views/blocks/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@

;; Show comments when the toggle is on
(when (and @show-comments?
open
(or @show-textarea?
(comments/get-comment-thread-uid @db/dsdb uid)))
[inline-comments/inline-comments (comments/get-comments-in-thread @db/dsdb (comments/get-comment-thread-uid @db/dsdb uid)) uid false])
Expand Down
18 changes: 15 additions & 3 deletions src/cljs/athens/views/comments/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
:comment/write-comment
;; There is a sequence for how the operations are to be executed because for some ops, information
;; related to prior op is needed. The sequence is:
;; - Create a thread if it does not exist with the author as member and subscriber to the thread.
;; - Create a thread if it does not exist with the block and the comment author as member and subscriber to the thread.
;; - Add comment to the thread.
;; - If the comment contains mentions to users not subscribed to the thread, then add them as subscribers and members.
;; - If this is not the first comment on the thread then add the author of comment as subscriber and member to the thread.
Expand All @@ -281,7 +281,10 @@
(let [thread-exists? (get-comment-thread-uid @db/dsdb uid)
thread-uid (or thread-exists?
(common.utils/gen-block-uid))

block-author (-> (common-db/get-block-document @db/dsdb [:block/uid uid])
:block/create
:event/auth
:presence/id)
{thread-members-uid :members-prop-uid
thread-subs-uid :subscribers-prop-uid
new-thread-op :new-thread-op} (when (not thread-exists?)
Expand All @@ -296,14 +299,23 @@
add-mentions-in-str-as-mem-subs-op (add-mentioned-users-as-member-and-subscriber @db/dsdb thread-members-uid thread-subs-uid comment-string thread-uid thread-exists? author)
add-author-as-mem-or-subs (when thread-exists?
(add-user-as-member-or-subscriber? @db/dsdb thread-uid (str "[[@" author "]]")))

notification-message (str "**((" uid "))**" "\n"
"*[[@" author "]] commented: " comment-string "*")
[add-block-author-as-sub-and-mem
block-author-notification-op] (when (and
(not= author block-author)
(not thread-exists?))
[(concat []
(add-new-member-or-subscriber-to-prop-uid @db/dsdb thread-members-uid (str "[[@" block-author "]]"))
(add-new-member-or-subscriber-to-prop-uid @db/dsdb thread-subs-uid (str "[[@" block-author "]]")))
(create-notification-op-for-users @db/dsdb uid [(str "[[@" block-author "]]")] author notification-message comment-uid "athens/notification/type/comment") ()])
notification-op (create-notification-op-for-comment @db/dsdb uid thread-uid author comment-string notification-message comment-uid)
ops (concat add-author-as-mem-or-subs
new-thread-op
[comment-op]
add-mentions-in-str-as-mem-subs-op
add-block-author-as-sub-and-mem
block-author-notification-op
notification-op)

comment-notif-op (composite/make-consequence-op {:op/type :comment-notif-op}
Expand Down
2 changes: 1 addition & 1 deletion src/cljs/athens/views/notifications/popover.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
(when (.. e -shiftKey)
(rf/dispatch [:right-sidebar/open-item [:node/title user-page-title]])))
:icon (r/as-element [:> BellFillIcon])}]
(when (> 0 num-notifications)
(when (> num-notifications 0)
[:> Badge {:position "absolute"
:bg "highlight"
:color "highlightContrast"
Expand Down