Microrefactoring

This commit is contained in:
virvar 2016-03-17 10:25:20 +03:00
parent 3f145c2059
commit 33348727a8
2 changed files with 19 additions and 17 deletions

View File

@ -9,12 +9,13 @@
(:require [om.next :as om :refer-macros [defui]]
[re-natal.support :as sup]
[messenger.state :as state]
[messenger.utils.utils :refer [log toast]]
[messenger.android.login :refer [login]]
[messenger.android.contacts-list :refer [contacts-list]]
[messenger.android.chat :refer [chat]]
[messenger.comm.pubsub :as pubsub]
[messenger.comm.intercom :refer [load-user-phone-number
load-user-whisper-identity]]))
[messenger.comm.intercom :as intercom :refer [load-user-phone-number
load-user-whisper-identity]]))
(def app-registry (.-AppRegistry js/React))
@ -35,20 +36,20 @@
(defui AppRoot
static om/IQuery
(query [this]
'[:page :contacts-ds :user-phone-number :confirmation-code])
'[:contacts-ds :user-phone-number :confirmation-code])
Object
(render [this]
(let [{:keys [page]} (om/props this)]
(navigator
{:initialRoute {:component login}
:renderScene (fn [route nav]
(when state/*nav-render*
(init-back-button-handler! nav)
(let [{:keys [component]}
(js->clj route :keywordize-keys true)]
(component (om/computed (om/props this)
{:nav nav})))))}))))
(navigator
{:initialRoute {:component login}
:renderScene (fn [route nav]
(when state/*nav-render*
(init-back-button-handler! nav)
(let [{:keys [component]}
(js->clj route :keywordize-keys true)]
(component (om/computed (om/props this)
{:nav nav})))))})))
;; TODO to service?
(swap! state/app-state assoc :contacts-ds
(data-source {:rowHasChanged (fn [row1 row2]
(not= row1 row2))}))

View File

@ -3,6 +3,10 @@
[om.next :as om]
[re-natal.support :as sup]))
(def ^{:dynamic true :private true} *nav-render*
"Flag to suppress navigator re-renders from outside om when pushing/popping."
true)
(set! js/React (js/require "react-native"))
(defonce app-state (atom {:component nil
@ -11,9 +15,6 @@
:confirmation-code nil
:channels {:pub-sub-publisher (chan)
:pub-sub-publication nil}}))
(def ^{:dynamic true :private true} *nav-render*
"Flag to suppress navigator re-renders from outside om when pushing/popping."
true)
(defmulti read om/dispatch)
(defmethod read :default
@ -37,4 +38,4 @@
(def pub-sub-path [:channels :pub-sub-publication])
(def user-notification-path [:user-notification])
(defn pub-sub-publisher [app] (get-in app pub-sub-bus-path))
(defn pub-sub-publisher [app] (get-in app pub-sub-bus-path))