[#10119] Android app UI is slow after backgorund

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2020-03-02 17:03:40 +01:00
parent 696ebbf67e
commit 5f2b29ee52
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
4 changed files with 20 additions and 28 deletions

View File

@ -60,19 +60,9 @@
(multiaccounts.update/multiaccount-update :photo-path photo-path {:dont-sync? true}))))
(fx/defn ensure-contact
[{:keys [db] :as cofx}
[{:keys [db]}
{:keys [public-key] :as contact}]
(let [new? (get-in db [:contacts/contacts public-key])
us? (= public-key (multiaccounts.model/current-public-key cofx))]
(fx/merge cofx
{:db (-> db
(update-in [:contacts/contacts public-key] merge contact))}
(cond
us?
(handle-update-from-contact-request contact)
new?
(transport.filters/load-contact contact)))))
{:db (update-in db [:contacts/contacts public-key] merge contact)})
(fx/defn upsert-contact
[{:keys [db] :as cofx}

View File

@ -15,10 +15,10 @@
[status-im.ethereum.core :as ethereum]
[status-im.native-module.core :as status]
[status-im.ens.core :as ens]
[cljs-bean.core :as clj-bean]
[status-im.utils.fx :as fx]
[taoensso.timbre :as log]
[status-im.ethereum.json-rpc :as json-rpc]))
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.utils.types :as types]))
(defn- js-obj->seq [obj]
;; Sometimes the filter will return a single object instead of a collection
@ -42,30 +42,31 @@
(let [chats (.-chats response-js)
contacts (.-contacts response-js)
installations (.-installations response-js)
raw-messages (.-rawMessages response-js)
messages (.-messages response-js)]
(cond
(seq installations)
(let [installation (.pop installations)]
(fx/merge cofx
{:dispatch-later [{:ms 20 :dispatch [::process response-js]}]}
(models.pairing/handle-installation (clj-bean/->clj installation))))
{:utils/dispatch-later [{:ms 20 :dispatch [::process response-js]}]}
(models.pairing/handle-installation (types/js->clj installation))))
(seq contacts)
(let [contact (.pop contacts)]
(fx/merge cofx
{:dispatch-later [{:ms 20 :dispatch [::process response-js]}]}
(handle-contact (-> contact (clj-bean/->clj) (data-store.contacts/<-rpc)))))
{:utils/dispatch-later [{:ms 20 :dispatch [::process response-js]}]}
(handle-contact (-> contact (types/js->clj) (data-store.contacts/<-rpc)))))
(seq chats)
(let [chat (.pop chats)]
(fx/merge cofx
{:dispatch-later [{:ms 20 :dispatch [::process response-js]}]}
(handle-chat (-> chat (clj-bean/->clj) (data-store.chats/<-rpc)))))
{:utils/dispatch-later [{:ms 20 :dispatch [::process response-js]}]}
(handle-chat (-> chat (types/js->clj) (data-store.chats/<-rpc)))))
(seq messages)
(let [message (.pop messages)]
(fx/merge cofx
{:dispatch-later [{:ms 20 :dispatch [::process response-js]}]}
(handle-message (-> message (clj-bean/->clj) (data-store.messages/<-rpc))))))))
{:utils/dispatch-later [{:ms 20 :dispatch [::process response-js]}]}
(handle-message (-> message (types/js->clj) (data-store.messages/<-rpc))))))))
(handlers/register-handler-fx
::process

View File

@ -1,11 +1,9 @@
(ns status-im.ui.components.large-toolbar.view
(:require [reagent.core :as reagent]
[cljs-bean.core :refer [->clj ->js]]
[status-im.ui.components.list.views :as list.views]
[status-im.ui.components.react :as react]
[status-im.ui.components.toolbar.view :as toolbar]
[status-im.ui.components.large-toolbar.styles :as styles]
[status-im.utils.platform :as platform]
[status-im.ui.components.animation :as animation])
(:require-macros [status-im.utils.views :as views]))

View File

@ -1,19 +1,22 @@
(ns status-im.utils.types
(:require
[cljs-bean.core :as clj-bean]))
(:refer-clojure :exclude [js->clj])
(:require [cljs-bean.core :as clj-bean]))
(defn to-string [s]
(if (keyword? s)
(name s)
s))
(defn js->clj [data]
(cljs.core/js->clj data :keywordize-keys true))
(defn clj->json [data]
(.stringify js/JSON (clj-bean/->js data)))
(defn json->clj [json]
(when-not (= json "undefined")
(try
(js->clj (.parse js/JSON json) :keywordize-keys true)
(js->clj (.parse js/JSON json))
(catch js/Error _ (when (string? json) json)))))
(def serialize clj->json)