Skip fetching 24h of discovery topics on a new account
Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
parent
d905aa7fa4
commit
2753b0ef60
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]}]
|
||||
|
|
Loading…
Reference in New Issue