Skip fetching 24h of discovery topics on a new account

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
Roman Volosovskyi 2019-04-16 10:14:04 +03:00 committed by Igor Mandrigin
parent d905aa7fa4
commit 2753b0ef60
No known key found for this signature in database
GPG Key ID: 4A0EDDE26E66BC8B
3 changed files with 27 additions and 14 deletions

View File

@ -66,7 +66,7 @@
{:keys [pubkey address mnemonic installation-id
keycard-instance-uid keycard-pairing keycard-paired-on]}
password
{:keys [seed-backed-up? login?] :or {login? true}}]
{:keys [seed-backed-up? login? new-account?] :or {login? true}}]
(let [normalized-address (utils.hex/normalize-hex address)
account {:public-key pubkey
:installation-id (or installation-id (get-in db [:accounts/new-installation-id]))
@ -84,7 +84,8 @@
:keycard-paired-on keycard-paired-on
:settings (constants/default-account-settings)
:syncing-on-mobile-network? false
:remember-syncing-choice? false}]
:remember-syncing-choice? false
:new-account? new-account?}]
(log/debug "account-created")
(when-not (string/blank? pubkey)
(fx/merge cofx

View File

@ -240,7 +240,8 @@
(re-frame/inject-cofx :accounts.create/get-signing-phrase)
(re-frame/inject-cofx :accounts.create/get-status)]
(fn [cofx [_ result password]]
(accounts.create/on-account-created cofx result password {:seed-backed-up? false})))
(accounts.create/on-account-created cofx result password {:seed-backed-up? false
:new-account? true})))
(handlers/register-handler-fx
:accounts.create.ui/create-new-account-button-pressed

View File

@ -308,6 +308,7 @@
" from " actual-from
" force-to? " force-to?
" to " to
" range " (- to from)
" cursor " cursor
" limit " actual-limit)
(.requestMessages (transport.utils/shh web3)
@ -722,18 +723,28 @@
there was no filter for the chat and messages for that
so the whole history for that topic needs to be re-fetched"
[{:keys [db now] :as cofx} {:keys [topic chat-id]}]
(let [{:keys [chat-ids last-request] :as current-mailserver-topic}
(let [{:keys [chat-ids] :as current-mailserver-topic}
(get-in db [:mailserver/topics topic] {:chat-ids #{}})]
(when-let [mailserver-topic (when-not (chat-ids chat-id)
(-> current-mailserver-topic
(assoc :last-request (- (quot now 1000)
(* 24 60 60)))
(update :chat-ids conj chat-id)))]
(fx/merge cofx
{:db (assoc-in db [:mailserver/topics topic] mailserver-topic)
:data-store/tx [(data-store.mailservers/save-mailserver-topic-tx
{:topic topic
:mailserver-topic mailserver-topic})]}))))
(when-not (contains? chat-ids chat-id)
(let [{:keys [new-account? public-key]} (:account/account db)
now-s (quot now 1000)
last-request (if (and new-account?
(or (= chat-id :discovery-topic)
(and
(string? chat-id)
(string/starts-with?
chat-id
public-key))))
(- now-s 10)
(- now-s max-request-range))
mailserver-topic (-> current-mailserver-topic
(assoc :last-request last-request)
(update :chat-ids conj chat-id))]
(fx/merge cofx
{:db (assoc-in db [:mailserver/topics topic] mailserver-topic)
:data-store/tx [(data-store.mailservers/save-mailserver-topic-tx
{:topic topic
:mailserver-topic mailserver-topic})]})))))
(fx/defn fetch-history
[{:keys [db] :as cofx} chat-id {:keys [from to]}]