[fix #2754] Don't update contact with old data
When contact-request message arrives, it may contain outdated info about contact including old profile picture.
This commit is contained in:
parent
9f35d265c8
commit
b7dadc78c2
|
@ -471,7 +471,7 @@
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:contact-request-received
|
:contact-request-received
|
||||||
(fn [{{:contacts/keys [contacts]} :db}
|
(fn [{{:contacts/keys [contacts]} :db}
|
||||||
[_ {:keys [from payload]}]]
|
[_ {:keys [from payload timestamp]}]]
|
||||||
(when from
|
(when from
|
||||||
(let [{{:keys [name profile-image address status fcm-token]} :contact
|
(let [{{:keys [name profile-image address status fcm-token]} :contact
|
||||||
{:keys [public private]} :keypair} payload
|
{:keys [public private]} :keypair} payload
|
||||||
|
@ -486,15 +486,22 @@
|
||||||
:fcm-token fcm-token}
|
:fcm-token fcm-token}
|
||||||
chat {:name name
|
chat {:name name
|
||||||
:chat-id from
|
:chat-id from
|
||||||
:contact-info (prn-str contact)}]
|
:contact-info (prn-str contact)}
|
||||||
|
prev-last-updated (get-in contacts [from :last-updated] 0)
|
||||||
|
;; NOTE(dmitryn) Workaround for old messages not having "payload.timestamp" attribute.
|
||||||
|
;; Get timestamp from message root level.
|
||||||
|
;; Root level "timestamp" is a unix ts in seconds.
|
||||||
|
timestamp' (or (:payload timestamp)
|
||||||
|
(* 1000 timestamp))]
|
||||||
|
|
||||||
(if-not existing-contact
|
(if-not existing-contact
|
||||||
(let [contact (assoc contact :pending? true)]
|
(let [contact (assoc contact :pending? true)]
|
||||||
{:dispatch-n [[:add-contacts [contact]]
|
{:dispatch-n [[:add-contacts [contact]]
|
||||||
[:add-chat from chat]]})
|
[:add-chat from chat]]})
|
||||||
(when-not (:pending? existing-contact)
|
(when-not (:pending? existing-contact)
|
||||||
{:dispatch-n [[:update-contact! contact]
|
(cond-> {:dispatch-n [[:update-chat! chat]
|
||||||
[:update-chat! chat]
|
[:watch-contact contact]]}
|
||||||
[:watch-contact contact]]}))))))
|
(<= prev-last-updated timestamp') (update :dispatch-n concat [[:update-contact! contact]]))))))))
|
||||||
|
|
||||||
;;GROUP
|
;;GROUP
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
[status-im.ui.screens.contacts.navigation]
|
[status-im.ui.screens.contacts.navigation]
|
||||||
[status-im.chat.console :as console-chat]
|
[status-im.chat.console :as console-chat]
|
||||||
[status-im.commands.events.loading :as loading-events]
|
[status-im.commands.events.loading :as loading-events]
|
||||||
[cljs.spec.alpha :as spec]))
|
[cljs.spec.alpha :as spec]
|
||||||
|
[status-im.protocol.web3.utils :as web3.utils]))
|
||||||
|
|
||||||
;;;; COFX
|
;;;; COFX
|
||||||
|
|
||||||
|
@ -68,7 +69,8 @@
|
||||||
:status status
|
:status status
|
||||||
:fcm-token fcm-token}
|
:fcm-token fcm-token}
|
||||||
:keypair {:public updates-public-key
|
:keypair {:public updates-public-key
|
||||||
:private updates-private-key}}}})))
|
:private updates-private-key}
|
||||||
|
:timestamp (web3.utils/timestamp)}}})))
|
||||||
|
|
||||||
(reg-fx
|
(reg-fx
|
||||||
::reset-pending-messages
|
::reset-pending-messages
|
||||||
|
|
Loading…
Reference in New Issue