diff --git a/src/cljs/athens/views/blocks/core.cljs b/src/cljs/athens/views/blocks/core.cljs index a8417273f8..1f10973802 100644 --- a/src/cljs/athens/views/blocks/core.cljs +++ b/src/cljs/athens/views/blocks/core.cljs @@ -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] diff --git a/src/cljs/athens/views/comments/inline.cljs b/src/cljs/athens/views/comments/inline.cljs index 4fe01e5562..644fcc5ec6 100644 --- a/src/cljs/athens/views/comments/inline.cljs +++ b/src/cljs/athens/views/comments/inline.cljs @@ -165,7 +165,7 @@ (defn comments-disclosure - [hide? num-comments] + [hide? num-comments last-comment] [:> Button (merge (when-not @hide? {:bg "background.upper" @@ -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}] @@ -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) @@ -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 diff --git a/src/cljs/athens/views/pages/block_page.cljs b/src/cljs/athens/views/pages/block_page.cljs index 23ef71b797..ceb86cd204 100644 --- a/src/cljs/athens/views/pages/block_page.cljs +++ b/src/cljs/athens/views/pages/block_page.cljs @@ -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)) @@ -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])]