Give all components a :display-name.

Make sure components use :reagent-render.
This commit is contained in:
Julien Eluard 2017-08-08 12:05:51 +02:00 committed by Roman Volosovskyi
parent 9e73097446
commit 646f61a406
13 changed files with 26 additions and 10 deletions

View File

@ -116,7 +116,8 @@
(fn [] (fn []
(.stop http-bridge) (.stop http-bridge)
(.removeEventListener app-state "change" app-state-change-handler)) (.removeEventListener app-state "change" app-state-change-handler))
:render :display-name "root"
:reagent-render
(fn [] (fn []
(when @view-id (when @view-id
(let [current-view (validate-current-view @view-id @signed-up?)] (let [current-view (validate-current-view @view-id @signed-up?)]

View File

@ -76,7 +76,8 @@
result (reaction (when @geolocation (get-places (:coords @geolocation) cur-loc-geocoded)))] result (reaction (when @geolocation (get-places (:coords @geolocation) cur-loc-geocoded)))]
(r/create-class (r/create-class
{:component-will-mount #(dispatch [:request-geolocation-update]) {:component-will-mount #(dispatch [:request-geolocation-update])
:render :display-name "current-location-view"
:reagent-render
(fn [] (fn []
(let [_ @result] (let [_ @result]
(when (and @cur-loc-geocoded (> (count (:features @cur-loc-geocoded)) 0)) (when (and @cur-loc-geocoded (> (count (:features @cur-loc-geocoded)) 0))

View File

@ -41,6 +41,7 @@
(r/create-class (r/create-class
{:component-did-update {:component-did-update
on-update on-update
:display-name "container"
:reagent-render :reagent-render
(fn [height & children] (fn [height & children]
[animated-view {:style (st/bottom-info-container height)} [animated-view {:style (st/bottom-info-container height)}
@ -69,7 +70,8 @@
(let [bottom-info (subscribe [:chat-ui-props :bottom-info]) (let [bottom-info (subscribe [:chat-ui-props :bottom-info])
contacts (subscribe [:get-contacts])] contacts (subscribe [:get-contacts])]
(r/create-class (r/create-class
{:reagent-render {:display-name "bottom-info-view"
:reagent-render
(fn [] (fn []
(let [{:keys [user-statuses message-status participants]} @bottom-info (let [{:keys [user-statuses message-status participants]} @bottom-info
participants (->> participants participants (->> participants

View File

@ -76,6 +76,7 @@
(if height (if height
(dispatch [:set-expandable-height key height]) (dispatch [:set-expandable-height key height])
(dispatch [:choose-predefined-expandable-height key :default]))) (dispatch [:choose-predefined-expandable-height key :default])))
:display-name "expandable-view"
:reagent-render :reagent-render
(fn [{:keys [draggable? custom-header]} & elements] (fn [{:keys [draggable? custom-header]} & elements]
@to-changed-height @changes-counter @max-height @to-changed-height @changes-counter @max-height

View File

@ -180,7 +180,8 @@
set-container-width-fn #(r/set-state component {:container-width %}) set-container-width-fn #(r/set-state component {:container-width %})
command (subscribe [:selected-chat-command])] command (subscribe [:selected-chat-command])]
(r/create-class (r/create-class
{:reagent-render {:display-name "input-view"
:reagent-render
(fn [{:keys [anim-margin single-line-input?]}] (fn [{:keys [anim-margin single-line-input?]}]
(let [{:keys [width height container-width]} (r/state component) (let [{:keys [width height container-width]} (r/state component)
command @command] command @command]
@ -246,7 +247,8 @@
container-anim-margin (anim/create-value 16) container-anim-margin (anim/create-value 16)
bottom-anim-margin (anim/create-value 14)] bottom-anim-margin (anim/create-value 14)]
(r/create-class (r/create-class
{:component-did-mount {:display-name "input-container"
:component-did-mount
(fn [] (fn []
(when-not (str/blank? @input-text) (when-not (str/blank? @input-text)
(.setValue anim-margin 0) (.setValue anim-margin 0)

View File

@ -371,6 +371,7 @@
(r/create-class (r/create-class
{:component-did-update {:component-did-update
on-update on-update
:display-name "message-container"
:reagent-render :reagent-render
(fn [_ & children] (fn [_ & children]
@layout-height @layout-height
@ -387,7 +388,8 @@
status (subscribe [:get-in [:message-data :user-statuses message-id my-identity]]) status (subscribe [:get-in [:message-data :user-statuses message-id my-identity]])
preview (subscribe [:get-in [:message-data :preview message-id :markup]])] preview (subscribe [:get-in [:message-data :preview message-id :markup]])]
(r/create-class (r/create-class
{:component-will-mount {:display-name "chat-message"
:component-will-mount
(fn [] (fn []
(let [{:keys [bot command] :as content} (get-in message [:content]) (let [{:keys [bot command] :as content} (get-in message [:content])
message' (assoc message :jail-id bot)] message' (assoc message :jail-id bot)]

View File

@ -50,7 +50,8 @@
:answered? answered? :answered? answered?
:loop? loop?}] :loop? loop?}]
(r/create-class (r/create-class
{:component-did-mount {:display-name "request-button"
:component-did-mount
(if @answered? (fn []) #(request-button-animation-logic context)) (if @answered? (fn []) #(request-button-animation-logic context))
:component-will-unmount :component-will-unmount
#(reset! loop? false) #(reset! loop? false)

View File

@ -21,7 +21,8 @@
(let [message (subscribe [:get-last-message chat-id]) (let [message (subscribe [:get-last-message chat-id])
preview (subscribe [:get-last-message-short-preview chat-id])] preview (subscribe [:get-last-message-short-preview chat-id])]
(r/create-class (r/create-class
{:component-will-mount {:display-name "message-content-text"
:component-will-mount
(fn [] (fn []
(when (and (get-in @message [:content :command]) (when (and (get-in @message [:content :command])
(not @preview)) (not @preview))

View File

@ -94,6 +94,7 @@
(let [to (scroll-to @prev-view-id @view-id)] (let [to (scroll-to @prev-view-id @view-id)]
(a/put! scroll-start [@main-swiper to])))) (a/put! scroll-start [@main-swiper to]))))
(reset! tabs-were-hidden? @tabs-hidden?)) (reset! tabs-were-hidden? @tabs-hidden?))
:display-name "main-tabs"
:reagent-render :reagent-render
(fn [] (fn []
[view common-st/flex [view common-st/flex

View File

@ -105,6 +105,7 @@
on-update on-update
:component-did-update :component-did-update
on-update on-update
:display-name "sync-state-gradient-view"
:reagent-render :reagent-render
(fn [] (fn []
[view st/sync-style-gradient [view st/sync-style-gradient

View File

@ -31,6 +31,7 @@
on-update on-update
:component-did-update :component-did-update
on-update on-update
:display-name "offline-view"
:reagent-render :reagent-render
(fn [{:keys [top]}] (fn [{:keys [top]}]
(when (or (= @network-status :offline) (= @sync-state :offline)) (when (or (= @network-status :offline) (= @sync-state :offline))

View File

@ -86,7 +86,8 @@
:component-will-unmount :component-will-unmount
(fn [] (fn []
(.stop http-bridge)) (.stop http-bridge))
:render :display-name "root"
:reagent-render
(fn [] (fn []
(when @view-id (when @view-id
(let [current-view (validate-current-view @view-id @signed-up?)] (let [current-view (validate-current-view @view-id @signed-up?)]

View File

@ -58,7 +58,8 @@
(let [~@vars-bindings] (let [~@vars-bindings]
(apply ~f ~args)))]))) (apply ~f ~args)))])))
(into {})) (into {}))
{:reagent-render {:display-name (name '~n)
:reagent-render
(fn ~params (fn ~params
(let [~@vars-bindings] (let [~@vars-bindings]
~body))})))))) ~body))}))))))