remove views pre-rendering hack
Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
parent
f38ffff7e1
commit
e3b283056c
1
.env
1
.env
|
@ -8,7 +8,6 @@ LOG_LEVEL=debug
|
||||||
LOG_LEVEL_STATUS_GO=info
|
LOG_LEVEL_STATUS_GO=info
|
||||||
QUEUE_MESSAGE_ENABLED=1
|
QUEUE_MESSAGE_ENABLED=1
|
||||||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||||
COMPILE_VIEWS_ENABLED=0
|
|
||||||
POW_TARGET=0.002
|
POW_TARGET=0.002
|
||||||
POW_TIME=1
|
POW_TIME=1
|
||||||
MIXPANEL_TOKEN=e1c71ae86923310ffb75de525d54cabf
|
MIXPANEL_TOKEN=e1c71ae86923310ffb75de525d54cabf
|
||||||
|
|
|
@ -8,7 +8,6 @@ LOG_LEVEL_STATUS_GO=info
|
||||||
JSC_ENABLED=1
|
JSC_ENABLED=1
|
||||||
QUEUE_MESSAGE_ENABLED=1
|
QUEUE_MESSAGE_ENABLED=1
|
||||||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||||
COMPILE_VIEWS_ENABLED=0
|
|
||||||
MIXPANEL_TOKEN=e1c71ae86923310ffb75de525d54cabf
|
MIXPANEL_TOKEN=e1c71ae86923310ffb75de525d54cabf
|
||||||
TESTFAIRY_TOKEN=969f6c921cb435cea1d41d1ea3f5b247d6026d55
|
TESTFAIRY_TOKEN=969f6c921cb435cea1d41d1ea3f5b247d6026d55
|
||||||
POW_TARGET=0.002
|
POW_TARGET=0.002
|
||||||
|
|
|
@ -8,7 +8,6 @@ LOG_LEVEL_STATUS_GO=info
|
||||||
JSC_ENABLED=1
|
JSC_ENABLED=1
|
||||||
QUEUE_MESSAGE_ENABLED=1
|
QUEUE_MESSAGE_ENABLED=1
|
||||||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||||
COMPILE_VIEWS_ENABLED=0
|
|
||||||
MIXPANEL_TOKEN=3f2e1a8970f159aa2a3d5dc5d65eab38
|
MIXPANEL_TOKEN=3f2e1a8970f159aa2a3d5dc5d65eab38
|
||||||
TESTFAIRY_TOKEN=969f6c921cb435cea1d41d1ea3f5b247d6026d55
|
TESTFAIRY_TOKEN=969f6c921cb435cea1d41d1ea3f5b247d6026d55
|
||||||
POW_TARGET=0.002
|
POW_TARGET=0.002
|
||||||
|
|
|
@ -9,7 +9,6 @@ LOG_LEVEL_STATUS_GO=info
|
||||||
JSC_ENABLED=1
|
JSC_ENABLED=1
|
||||||
QUEUE_MESSAGE_ENABLED=0
|
QUEUE_MESSAGE_ENABLED=0
|
||||||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||||
COMPILE_VIEWS_ENABLED=0
|
|
||||||
MIXPANEL_TOKEN=2584e00100d319d12e538cc4d0fa9fc1
|
MIXPANEL_TOKEN=2584e00100d319d12e538cc4d0fa9fc1
|
||||||
TESTFAIRY_TOKEN=969f6c921cb435cea1d41d1ea3f5b247d6026d55
|
TESTFAIRY_TOKEN=969f6c921cb435cea1d41d1ea3f5b247d6026d55
|
||||||
POW_TARGET=0.002
|
POW_TARGET=0.002
|
||||||
|
|
|
@ -71,28 +71,10 @@
|
||||||
[status-bar.view/status-bar {:type (if (= view-id :wallet) :wallet-tab :main)}]
|
[status-bar.view/status-bar {:type (if (= view-id :wallet) :wallet-tab :main)}]
|
||||||
[react/view common.styles/main-container
|
[react/view common.styles/main-container
|
||||||
|
|
||||||
[react/with-activity-indicator
|
(case view-id
|
||||||
{:enabled? (= :home view-id)
|
:home [home/home]
|
||||||
:preview [react/view {}]}
|
:wallet [wallet/wallet]
|
||||||
[react/navigation-wrapper
|
:my-profile [profile.user/my-profile])
|
||||||
{:component home/home
|
|
||||||
:views :home
|
|
||||||
:current-view view-id}]]
|
|
||||||
|
|
||||||
[react/with-activity-indicator
|
|
||||||
{:enabled? (= :wallet view-id)
|
|
||||||
:preview [react/view {}]}
|
|
||||||
[react/navigation-wrapper
|
|
||||||
{:component wallet/wallet
|
|
||||||
:views :wallet
|
|
||||||
:current-view view-id}]]
|
|
||||||
|
|
||||||
[react/with-activity-indicator
|
|
||||||
{:enabled? (= :my-profile view-id)
|
|
||||||
:preview [react/view {}]}
|
|
||||||
[react/navigation-wrapper
|
|
||||||
{:component profile.user/my-profile
|
|
||||||
:views :my-profile
|
|
||||||
:current-view view-id}]]
|
|
||||||
(when tab-bar-visible?
|
(when tab-bar-visible?
|
||||||
[tabs view-id])]]))
|
[tabs view-id])]]))
|
||||||
|
|
|
@ -45,72 +45,7 @@
|
||||||
[status-im.ui.screens.intro.views :refer [intro]]
|
[status-im.ui.screens.intro.views :refer [intro]]
|
||||||
[status-im.ui.screens.accounts.create.views :refer [create-account]]
|
[status-im.ui.screens.accounts.create.views :refer [create-account]]
|
||||||
[status-im.ui.screens.usage-data.views :refer [usage-data]]
|
[status-im.ui.screens.usage-data.views :refer [usage-data]]
|
||||||
[status-im.ui.screens.profile.seed.views :refer [backup-seed]]
|
[status-im.ui.screens.profile.seed.views :refer [backup-seed]]))
|
||||||
[status-im.utils.config :as config]))
|
|
||||||
|
|
||||||
;;; defines hierarchy of views, when parent screen is opened children screens
|
|
||||||
;;; are pre-rendered, currently it is:
|
|
||||||
;;;
|
|
||||||
;;; root-
|
|
||||||
;;; |
|
|
||||||
;;; - main-tabs -
|
|
||||||
;;; | |
|
|
||||||
;;; - chat |
|
|
||||||
;;; wallet
|
|
||||||
;;; - wallet-send-transaction -
|
|
||||||
;;; | |
|
|
||||||
;;; | - choose-recipient
|
|
||||||
;;; | |
|
|
||||||
;;; | - wallet-transaction-sent
|
|
||||||
;;; |
|
|
||||||
;;; - transactions-history, unsigned-transactions
|
|
||||||
;;; |
|
|
||||||
;;; - wallet-request-transaction -
|
|
||||||
;;; | |
|
|
||||||
;;; | - choose-recipient
|
|
||||||
;;; |
|
|
||||||
;;; my-profile
|
|
||||||
;;; - edit-my-profile -
|
|
||||||
;;; |
|
|
||||||
;;; - profile-photo-capture
|
|
||||||
(views/compile-views
|
|
||||||
root-view
|
|
||||||
[{:views #{:home :wallet :my-profile}
|
|
||||||
:component main-tabs}
|
|
||||||
|
|
||||||
{:view :chat
|
|
||||||
:hide? (not android?)
|
|
||||||
:component chat}
|
|
||||||
|
|
||||||
{:view :wallet-send-transaction
|
|
||||||
:parent :wallet
|
|
||||||
:hide? (not android?)
|
|
||||||
:component send-transaction}
|
|
||||||
|
|
||||||
{:view :wallet-request-transaction
|
|
||||||
:parent :wallet
|
|
||||||
:component request-transaction}
|
|
||||||
|
|
||||||
{:view :wallet-request-assets
|
|
||||||
:parent :wallet-request-transaction
|
|
||||||
:component wallet.components/request-assets}
|
|
||||||
|
|
||||||
{:view :choose-recipient
|
|
||||||
:parent :wallet-send-transaction
|
|
||||||
:hide? true
|
|
||||||
:component choose-recipient}
|
|
||||||
|
|
||||||
{:view :wallet-transaction-sent
|
|
||||||
:parent :wallet-send-transaction
|
|
||||||
:component transaction-sent}
|
|
||||||
|
|
||||||
{:views #{:transactions-history :unsigned-transactions}
|
|
||||||
:parent :wallet
|
|
||||||
:component wallet-transactions/transactions}
|
|
||||||
|
|
||||||
{:view :profile-photo-capture
|
|
||||||
:parent :my-profile
|
|
||||||
:component profile-photo-capture}])
|
|
||||||
|
|
||||||
(defn get-main-component [view-id]
|
(defn get-main-component [view-id]
|
||||||
(case view-id
|
(case view-id
|
||||||
|
@ -188,13 +123,5 @@
|
||||||
(let [component (get-main-component view-id)
|
(let [component (get-main-component view-id)
|
||||||
main-screen-view (create-main-screen-view view-id)]
|
main-screen-view (create-main-screen-view view-id)]
|
||||||
[main-screen-view common-styles/flex
|
[main-screen-view common-styles/flex
|
||||||
(if (and config/compile-views-enabled?
|
[component]
|
||||||
signed-up?
|
|
||||||
(#{:home :wallet :my-profile :chat :wallet-send-transaction
|
|
||||||
:choose-recipient :wallet-transaction-sent :transactions-history
|
|
||||||
:unsigned-transactions :wallet-request-transaction :edit-my-profile
|
|
||||||
:profile-photo-capture :wallet-request-assets}
|
|
||||||
view-id))
|
|
||||||
[root-view]
|
|
||||||
[component])
|
|
||||||
[main-modal]]))))
|
[main-modal]]))))
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
(def add-custom-mailservers-enabled? (enabled? (get-config :ADD_CUSTOM_MAILSERVERS_ENABLED "1")))
|
(def add-custom-mailservers-enabled? (enabled? (get-config :ADD_CUSTOM_MAILSERVERS_ENABLED "1")))
|
||||||
(def rn-bridge-threshold-warnings-enabled? (enabled? (get-config :RN_BRIDGE_THRESHOLD_WARNINGS 0)))
|
(def rn-bridge-threshold-warnings-enabled? (enabled? (get-config :RN_BRIDGE_THRESHOLD_WARNINGS 0)))
|
||||||
(def compile-views-enabled? (enabled? (get-config :COMPILE_VIEWS_ENABLED 0)))
|
|
||||||
(def mixpanel-token (get-config :MIXPANEL_TOKEN))
|
(def mixpanel-token (get-config :MIXPANEL_TOKEN))
|
||||||
(def default-network (get-config :DEFAULT_NETWORK))
|
(def default-network (get-config :DEFAULT_NETWORK))
|
||||||
;; the default value should be a string for `enabled?` to work correctly.
|
;; the default value should be a string for `enabled?` to work correctly.
|
||||||
|
|
|
@ -66,209 +66,3 @@
|
||||||
(fn ~params
|
(fn ~params
|
||||||
(let [~@vars-bindings]
|
(let [~@vars-bindings]
|
||||||
~body))})))))))
|
~body))})))))))
|
||||||
|
|
||||||
(defn check-view [all {:keys [view views component hide? parent]}]
|
|
||||||
(let [parent (or parent :root)
|
|
||||||
views (or views #{view})
|
|
||||||
comp {:views views
|
|
||||||
:component component
|
|
||||||
:hide? hide?}]
|
|
||||||
(-> all
|
|
||||||
(assoc-in [:components views] comp)
|
|
||||||
(update-in [:view->children parent]
|
|
||||||
(fn [children]
|
|
||||||
(let [children (or children [])]
|
|
||||||
(conj children views))))
|
|
||||||
(update :view->components
|
|
||||||
(fn [view->components]
|
|
||||||
(reduce (fn [view->components view]
|
|
||||||
(assoc view->components view views))
|
|
||||||
view->components views))))))
|
|
||||||
|
|
||||||
(defn -build-tree [views]
|
|
||||||
(reduce check-view {:components {}
|
|
||||||
:view->components {}
|
|
||||||
:view->children {}} views))
|
|
||||||
|
|
||||||
(defn -get-all-views
|
|
||||||
[{:keys [view->children] :as config} component]
|
|
||||||
(let [children (reduce clojure.set/union (keep view->children component))]
|
|
||||||
(reduce clojure.set/union
|
|
||||||
(concat [component]
|
|
||||||
children
|
|
||||||
(map (fn [child]
|
|
||||||
(-get-all-views config child))
|
|
||||||
(reduce clojure.set/union
|
|
||||||
(map view->children component)))))))
|
|
||||||
|
|
||||||
(defn -get-grandchildren [{:keys [view->children] :as config} children]
|
|
||||||
(into {}
|
|
||||||
(filter
|
|
||||||
(fn [[_ children]]
|
|
||||||
(not (nil? children)))
|
|
||||||
(map (fn [child]
|
|
||||||
[child (get view->children child)])
|
|
||||||
(reduce clojure.set/union children)))))
|
|
||||||
|
|
||||||
(defn -generate-component
|
|
||||||
[{:keys [components view->children] :as config} view-sym component-name]
|
|
||||||
(let [component-config (get components component-name)
|
|
||||||
children (get view->children component-name)
|
|
||||||
grandchildren (-get-grandchildren config children)]
|
|
||||||
`[status-im.ui.components.react/view
|
|
||||||
{:flex
|
|
||||||
~(if (= :root component-name)
|
|
||||||
1
|
|
||||||
`(if (contains?
|
|
||||||
~(disj (-get-all-views config #{component-name}) component-name)
|
|
||||||
~view-sym)
|
|
||||||
1
|
|
||||||
0))}
|
|
||||||
~@(when component-config
|
|
||||||
`[status-im.ui.components.react/navigation-wrapper
|
|
||||||
~(assoc component-config :current-view view-sym)])
|
|
||||||
~@(map (fn [child]
|
|
||||||
`[status-im.ui.components.react/navigation-wrapper
|
|
||||||
~(assoc (get components child) :current-view view-sym)])
|
|
||||||
children)
|
|
||||||
~@(map (fn [[component-name children]]
|
|
||||||
`[status-im.ui.components.react/navigation-wrapper
|
|
||||||
{:component [status-im.ui.components.react/with-empty-preview
|
|
||||||
~(-generate-component config view-sym component-name)]
|
|
||||||
:views ~(conj
|
|
||||||
(reduce
|
|
||||||
clojure.set/union
|
|
||||||
(map (fn [child]
|
|
||||||
(-get-all-views config child))
|
|
||||||
children))
|
|
||||||
component-name)
|
|
||||||
:hide? true
|
|
||||||
:current-view ~view-sym}])
|
|
||||||
grandchildren)]))
|
|
||||||
|
|
||||||
(defn -compile-views [n views]
|
|
||||||
(let [view-sym (gensym "view-id")]
|
|
||||||
`(defview ~n []
|
|
||||||
(letsubs [~view-sym [:get :view-id]]
|
|
||||||
~(let [tree (-build-tree views)]
|
|
||||||
(-generate-component tree view-sym :root))))))
|
|
||||||
|
|
||||||
(defmacro compile-views
|
|
||||||
[n views]
|
|
||||||
(-compile-views n views))
|
|
||||||
|
|
||||||
(comment
|
|
||||||
|
|
||||||
(-compile-views
|
|
||||||
'root-view
|
|
||||||
'[{:views #{:home :wallet :my-profile}
|
|
||||||
:component main-tabs}
|
|
||||||
|
|
||||||
{:view :chat
|
|
||||||
:hide? (not android?)
|
|
||||||
:component chat}
|
|
||||||
|
|
||||||
{:view :wallet-send-transaction
|
|
||||||
:parent :wallet
|
|
||||||
:component send-transaction}
|
|
||||||
|
|
||||||
{:view :wallet-request-transaction
|
|
||||||
:parent :wallet
|
|
||||||
:component request-transaction}
|
|
||||||
|
|
||||||
{:view :choose-recipient
|
|
||||||
:parent :wallet-send-transaction
|
|
||||||
:component choose-recipient}
|
|
||||||
|
|
||||||
{:view :wallet-transaction-sent
|
|
||||||
:parent :wallet-send-transaction
|
|
||||||
:component transaction-sent}
|
|
||||||
|
|
||||||
{:views #{:transactions-history :unsigned-transactions}
|
|
||||||
:parent :wallet
|
|
||||||
:component wallet-transactions/transactions}
|
|
||||||
|
|
||||||
{:view :edit-my-profile
|
|
||||||
:parent :profile
|
|
||||||
:component edit-my-profile}])
|
|
||||||
|
|
||||||
(status-im.utils.views/defview
|
|
||||||
root-view
|
|
||||||
[]
|
|
||||||
(status-im.utils.views/letsubs
|
|
||||||
[view-id76826 [:get :view-id]]
|
|
||||||
[status-im.ui.components.react/view
|
|
||||||
{:flex 1}
|
|
||||||
[status-im.ui.components.react/navigation-wrapper
|
|
||||||
{:views #{:home :wallet :my-profile},
|
|
||||||
:component main-tabs,
|
|
||||||
:hide? nil,
|
|
||||||
:current-view view-id76826}]
|
|
||||||
[status-im.ui.components.react/navigation-wrapper
|
|
||||||
{:views #{:chat},
|
|
||||||
:component chat,
|
|
||||||
:hide? (not android?),
|
|
||||||
:current-view view-id76826}]
|
|
||||||
[status-im.ui.components.react/navigation-wrapper
|
|
||||||
{:hide? true,
|
|
||||||
:component [status-im.ui.components.react/with-empty-preview
|
|
||||||
[status-im.ui.components.react/view
|
|
||||||
{:flex (if
|
|
||||||
(clojure.core/contains?
|
|
||||||
#{:wallet-request-transaction
|
|
||||||
:wallet-send-transaction
|
|
||||||
:choose-recipient
|
|
||||||
:wallet-transaction-sent
|
|
||||||
:transactions-history
|
|
||||||
:unsigned-transactions}
|
|
||||||
view-id76826)
|
|
||||||
1
|
|
||||||
0)}
|
|
||||||
[status-im.ui.components.react/navigation-wrapper
|
|
||||||
{:views #{:wallet-send-transaction},
|
|
||||||
:component send-transaction,
|
|
||||||
:hide? nil,
|
|
||||||
:current-view view-id76826}]
|
|
||||||
[status-im.ui.components.react/navigation-wrapper
|
|
||||||
{:views #{:wallet-request-transaction},
|
|
||||||
:component request-transaction,
|
|
||||||
:hide? nil,
|
|
||||||
:current-view view-id76826}]
|
|
||||||
[status-im.ui.components.react/navigation-wrapper
|
|
||||||
{:views #{:transactions-history :unsigned-transactions},
|
|
||||||
:component wallet-transactions/transactions,
|
|
||||||
:hide? nil,
|
|
||||||
:current-view view-id76826}]
|
|
||||||
[status-im.ui.components.react/navigation-wrapper
|
|
||||||
{:hide? true,
|
|
||||||
:component [status-im.ui.components.react/with-empty-preview
|
|
||||||
[status-im.ui.components.react/view
|
|
||||||
{:flex (if
|
|
||||||
(clojure.core/contains?
|
|
||||||
#{:choose-recipient
|
|
||||||
:wallet-transaction-sent}
|
|
||||||
view-id76826)
|
|
||||||
1
|
|
||||||
0)}
|
|
||||||
[status-im.ui.components.react/navigation-wrapper
|
|
||||||
{:views #{:choose-recipient},
|
|
||||||
:component choose-recipient,
|
|
||||||
:hide? nil,
|
|
||||||
:current-view view-id76826}]
|
|
||||||
[status-im.ui.components.react/navigation-wrapper
|
|
||||||
{:views #{:wallet-transaction-sent},
|
|
||||||
:component transaction-sent,
|
|
||||||
:hide? nil,
|
|
||||||
:current-view view-id76826}]]],
|
|
||||||
:current-view view-id76826,
|
|
||||||
:views #{:wallet-send-transaction
|
|
||||||
:choose-recipient
|
|
||||||
:wallet-transaction-sent}}]]],
|
|
||||||
:current-view view-id76826,
|
|
||||||
:views #{:wallet-request-transaction
|
|
||||||
:wallet
|
|
||||||
:wallet-send-transaction
|
|
||||||
:choose-recipient
|
|
||||||
:wallet-transaction-sent
|
|
||||||
:transactions-history
|
|
||||||
:unsigned-transactions}}]])))
|
|
||||||
|
|
Loading…
Reference in New Issue