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

hide comments on load, show last comment while in closed state #2294

Merged
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
4 changes: 3 additions & 1 deletion src/cljs/athens/views/blocks/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,9 @@
(when (and @show-comments?
(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])
(cond
@show-textarea? [inline-comments/inline-comments (comments/get-comments-in-thread @db/dsdb (comments/get-comment-thread-uid @db/dsdb uid)) uid false]
:else [inline-comments/inline-comments (comments/get-comments-in-thread @db/dsdb (comments/get-comment-thread-uid @db/dsdb uid)) uid true]))

[presence/inline-presence-el uid]

Expand Down
14 changes: 11 additions & 3 deletions src/cljs/athens/views/comments/inline.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@


(defn comments-disclosure
[hide? num-comments]
[hide? num-comments last-comment]
[:> Button (merge
(when-not @hide?
{:bg "background.upper"
Expand All @@ -182,7 +182,14 @@
[:<>
[:> ChevronRightIcon]
[:> CommentCounter {:count num-comments}]
[:> Text {:pl 1.5} "Comments"]]
[:> Text {:pl 1.5} "Comments"]
[:> HStack
[:> Box
(:author last-comment)]
[:> Box
(:string last-comment)]
[:> Box
(timeAgo (:time last-comment))]]]
[:<>
[:> ChevronDownIcon]
[:> CommentCounter {:count num-comments}]
Expand All @@ -199,6 +206,7 @@
(fn [data uid _hide?]
(let [num-comments (count data)
username (rf/subscribe [:username])
last-comment (last data)
;; hacky way to detect if user just wanted to start the first comment, but the block-uid of the textarea
;; isn't accessible globally
focus-textarea-if-opening-first-time #(when (zero? num-comments)
Expand All @@ -215,7 +223,7 @@
:borderRadius "md"
:align "stretch"})

[comments-disclosure hide? num-comments]
[comments-disclosure hide? num-comments last-comment]

(when-not @hide?
[:> Box {:pl 8
Expand Down
8 changes: 5 additions & 3 deletions src/cljs/athens/views/pages/block_page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@
properties-enabled? (rf/subscribe [:feature-flags/enabled? :properties])]

(fn [block]
(let [{:block/keys [string children uid properties] :db/keys [id]} block]
(let [{:block/keys [string children uid properties] :db/keys [id]} block
show-comments? (rf/subscribe [:comment/show-comments?])
show-textarea? (rf/subscribe [:comment/show-editor? uid])]
(when (not= string (:string/previous @state))
(swap! state assoc :string/previous string :string/local string))

Expand Down Expand Up @@ -141,8 +143,8 @@
;; Show comments when the toggle is on
[:> Box {:ml "4%"
:w "100%"}
(when (or @(rf/subscribe [:comment/show-editor? uid])
(and @(rf/subscribe [:comment/show-comments?])
(when (or @show-textarea?
(and @show-comments?
(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