Skip to content

Commit

Permalink
Merge pull request #2307 from sid597/fix-comments-not-rendering
Browse files Browse the repository at this point in the history
Fix comments not rendering
  • Loading branch information
tangjeff0 authored Aug 25, 2022
2 parents 962c464 + 381e887 commit 83b2d89
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/cljs/athens/views/comments/inline.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@


(defn inline-comments
[_data _uid hide?]
[_data _comment-block-uid hide?]
(when (comments.core/enabled?)
(let [hide? (r/atom hide?)
block-uid (common.utils/gen-block-uid)
value-atom (r/atom "")
show-edit-atom? (r/atom true)]
(fn [data uid _hide?]
(fn [data comment-block-uid _hide?]
(let [num-comments (count data)
username (rf/subscribe [:username])
last-comment (last data)
Expand Down Expand Up @@ -243,7 +243,7 @@
[_uid _d-key-down]
(when (not (str/blank? @value-atom))
;; Passing username because we need the username for other ops before the block is created.
(rf/dispatch [:comment/write-comment uid @value-atom @username])
(rf/dispatch [:comment/write-comment comment-block-uid @value-atom @username])
(reset! value-atom "")
(rf/dispatch [:editing/uid block-uid])))
tab-handler (fn jetsam-tab-handler
Expand Down
36 changes: 23 additions & 13 deletions src/cljs/athens/views/pages/block_page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[athens.views.comments.inline :as inline-comments]
[athens.views.pages.node-page :as node-page]
[komponentit.autosize :as autosize]
[re-frame.core :as rf :refer [dispatch subscribe]]
[re-frame.core :as rf :refer [dispatch]]
[reagent.core :as r]))


Expand Down Expand Up @@ -94,27 +94,36 @@


(defn block-page-el
[_block]
(let [state (r/atom {:string/local nil
:string/previous nil})
properties-enabled? (rf/subscribe [:feature-flags/enabled? :properties])]
[block]
(let [state (r/atom {:string/local nil
:string/previous nil})
uid (:block/uid block)
show-comments? (rf/subscribe [:comment/show-comments?])
show-textarea? (rf/subscribe [:comment/show-editor? uid])
is-editing? (rf/subscribe [:editing/is-editing uid])
right-sidebar-contains-items? (rf/subscribe [:right-sidebar/contains-item? [:block/uid uid]])
properties-enabled? (rf/subscribe [:feature-flags/enabled? :properties])]

(fn [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])]
(let [{:block/keys [string
children
uid
properties]
:db/keys [id]} block
thread-uid (comments/get-comment-thread-uid @db/dsdb uid)
comments-data (comments/get-comments-in-thread @db/dsdb thread-uid)]
(when (not= string (:string/previous @state))
(swap! state assoc :string/previous string :string/local string))

[:> Box

;; Header
[:> PageHeader {:onClickOpenInSidebar (when-not @(subscribe [:right-sidebar/contains-item? [:block/uid uid]])
[:> PageHeader {:onClickOpenInSidebar (when-not @right-sidebar-contains-items?
#(dispatch [:right-sidebar/open-item [:block/uid uid]]))}

;; Parent Context
[parents-el uid id]
[:> TitleContainer {:isEditing @(subscribe [:editing/is-editing uid])
[:> TitleContainer {:isEditing @is-editing?
:onClick (fn [e]
(.. e preventDefault)
(if (.. e -shiftKey)
Expand All @@ -127,7 +136,7 @@
(dispatch [:editing/uid uid])))}
[autosize/textarea
{:value (:string/local @state)
:class (when @(subscribe [:editing/is-editing uid]) "is-editing")
:class (when @is-editing? "is-editing")
:id (str "editable-uid-" uid)
;; :auto-focus true
:on-blur (fn [_]
Expand All @@ -145,8 +154,9 @@
:w "100%"}
(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])]
thread-uid))
^{:key uid}
[inline-comments/inline-comments comments-data uid false])]

;; Properties
(when (and @properties-enabled?
Expand Down

0 comments on commit 83b2d89

Please sign in to comment.