remove message cache
message cache was initialized when logging-in so it was basically useless it was causing a bug when switching account and getting a contact request from the same user in 2 accounts without killing the app because the cache was not reset and the subsequent contact requests were ignored Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
0d2849d955
commit
baa471a929
|
@ -3,7 +3,6 @@
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.native-module.core :as status]
|
[status-im.native-module.core :as status]
|
||||||
[status-im.transport.message-cache :as message-cache]
|
|
||||||
[status-im.utils.datetime :as datetime]
|
[status-im.utils.datetime :as datetime]
|
||||||
[status-im.utils.ethereum.core :as utils]
|
[status-im.utils.ethereum.core :as utils]
|
||||||
[status-im.utils.handlers :as handlers]
|
[status-im.utils.handlers :as handlers]
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
(defrecord ContactRequest [name profile-image address fcm-token]
|
(defrecord ContactRequest [name profile-image address fcm-token]
|
||||||
message/StatusMessage
|
message/StatusMessage
|
||||||
(send [this chat-id {:keys [db random-id] :as cofx}]
|
(send [this chat-id {:keys [db random-id] :as cofx}]
|
||||||
(let [message-id (transport.utils/message-id this)
|
(let [topic (transport.utils/get-topic random-id)
|
||||||
topic (transport.utils/get-topic random-id)
|
|
||||||
on-success (fn [sym-key sym-key-id]
|
on-success (fn [sym-key sym-key-id]
|
||||||
(re-frame/dispatch [:contact/send-new-sym-key
|
(re-frame/dispatch [:contact/send-new-sym-key
|
||||||
{:sym-key-id sym-key-id
|
{:sym-key-id sym-key-id
|
||||||
|
@ -42,46 +41,34 @@
|
||||||
(handlers-macro/merge-fx cofx
|
(handlers-macro/merge-fx cofx
|
||||||
{:shh/get-new-sym-key {:web3 (:web3 db)
|
{:shh/get-new-sym-key {:web3 (:web3 db)
|
||||||
:on-success on-success}}
|
:on-success on-success}}
|
||||||
(protocol/init-chat chat-id topic)
|
(protocol/init-chat chat-id topic))))
|
||||||
#_(protocol/requires-ack message-id chat-id))))
|
|
||||||
(receive [this chat-id signature {:keys [db] :as cofx}]
|
(receive [this chat-id signature {:keys [db] :as cofx}]
|
||||||
(let [message-id (transport.utils/message-id this)
|
(let [topic (transport.utils/get-topic chat-id)]
|
||||||
topic (transport.utils/get-topic chat-id)]
|
(handlers-macro/merge-fx cofx
|
||||||
(when (protocol/is-new? message-id)
|
{:dispatch [:inbox/request-messages {:topics [topic]}]}
|
||||||
(handlers-macro/merge-fx cofx
|
(contacts/receive-contact-request signature
|
||||||
#_(protocol/ack message-id chat-id)
|
this)))))
|
||||||
{:dispatch [:inbox/request-messages {:topics [topic]}]}
|
|
||||||
(contacts/receive-contact-request signature
|
|
||||||
this))))))
|
|
||||||
|
|
||||||
(defrecord ContactRequestConfirmed [name profile-image address fcm-token]
|
(defrecord ContactRequestConfirmed [name profile-image address fcm-token]
|
||||||
message/StatusMessage
|
message/StatusMessage
|
||||||
(send [this chat-id cofx]
|
(send [this chat-id cofx]
|
||||||
(let [message-id (transport.utils/message-id this)]
|
(handlers-macro/merge-fx cofx
|
||||||
(handlers-macro/merge-fx cofx
|
(protocol/send {:chat-id chat-id
|
||||||
#_(protocol/requires-ack message-id chat-id)
|
:payload this})))
|
||||||
(protocol/send {:chat-id chat-id
|
|
||||||
:payload this}))))
|
|
||||||
(receive [this chat-id signature cofx]
|
(receive [this chat-id signature cofx]
|
||||||
(let [message-id (transport.utils/message-id this)]
|
(handlers-macro/merge-fx cofx
|
||||||
(when (protocol/is-new? message-id)
|
(contacts/receive-contact-request-confirmation signature
|
||||||
(handlers-macro/merge-fx cofx
|
this))))
|
||||||
#_(protocol/ack message-id chat-id)
|
|
||||||
(contacts/receive-contact-request-confirmation signature
|
|
||||||
this))))))
|
|
||||||
|
|
||||||
(defrecord ContactUpdate [name profile-image]
|
(defrecord ContactUpdate [name profile-image]
|
||||||
message/StatusMessage
|
message/StatusMessage
|
||||||
(send [this _ {:keys [db] :as cofx}]
|
(send [this _ {:keys [db] :as cofx}]
|
||||||
(let [message-id (transport.utils/message-id this)
|
(let [public-keys (remove nil? (map :public-key (vals (:contacts/contacts db))))]
|
||||||
public-keys (remove nil? (map :public-key (vals (:contacts/contacts db))))]
|
|
||||||
(handlers-macro/merge-fx cofx
|
(handlers-macro/merge-fx cofx
|
||||||
(protocol/multi-send-by-pubkey {:public-keys public-keys
|
(protocol/multi-send-by-pubkey {:public-keys public-keys
|
||||||
:payload this}))))
|
:payload this}))))
|
||||||
(receive [this chat-id signature cofx]
|
(receive [this chat-id signature cofx]
|
||||||
(let [message-id (transport.utils/message-id this)]
|
(handlers-macro/merge-fx cofx
|
||||||
(when (protocol/is-new? message-id)
|
(contacts/receive-contact-update chat-id
|
||||||
(handlers-macro/merge-fx cofx
|
signature
|
||||||
(contacts/receive-contact-update chat-id
|
this))))
|
||||||
signature
|
|
||||||
this))))))
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
(:require [status-im.utils.config :as config]
|
(:require [status-im.utils.config :as config]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.chat.core :as chat]
|
[status-im.chat.core :as chat]
|
||||||
[status-im.transport.message-cache :as message-cache]
|
|
||||||
[status-im.transport.db :as transport.db]
|
[status-im.transport.db :as transport.db]
|
||||||
[status-im.transport.message.core :as message]
|
[status-im.transport.message.core :as message]
|
||||||
[status-im.transport.utils :as transport.utils]))
|
[status-im.transport.utils :as transport.utils]))
|
||||||
|
@ -22,12 +21,6 @@
|
||||||
([chat-id topic {:keys [db] :as cofx}]
|
([chat-id topic {:keys [db] :as cofx}]
|
||||||
{:db (assoc-in db [:transport/chats chat-id] (transport.db/create-chat topic))}))
|
{:db (assoc-in db [:transport/chats chat-id] (transport.db/create-chat topic))}))
|
||||||
|
|
||||||
(defn is-new?
|
|
||||||
"Determines if given message-id already exists in in-memory message cache"
|
|
||||||
[message-id]
|
|
||||||
(when-not (message-cache/exists? message-id)
|
|
||||||
(message-cache/add! message-id)))
|
|
||||||
|
|
||||||
#_(defn requires-ack [message-id chat-id {:keys [db] :as cofx}]
|
#_(defn requires-ack [message-id chat-id {:keys [db] :as cofx}]
|
||||||
{:db (update-in db [:transport/chats chat-id :pending-ack] conj message-id)})
|
{:db (update-in db [:transport/chats chat-id :pending-ack] conj message-id)})
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
(ns ^{:doc "Message caching API for message deduplication"}
|
|
||||||
status-im.transport.message-cache
|
|
||||||
(:refer-clojure :exclude [exists?]))
|
|
||||||
|
|
||||||
(defonce messages-set (atom #{}))
|
|
||||||
|
|
||||||
(defn init!
|
|
||||||
[messages]
|
|
||||||
(reset! messages-set (set (map :message-id messages))))
|
|
||||||
|
|
||||||
(defn add!
|
|
||||||
[message-id]
|
|
||||||
(when message-id
|
|
||||||
(swap! messages-set conj message-id)))
|
|
||||||
|
|
||||||
(defn exists?
|
|
||||||
[message-id]
|
|
||||||
(when message-id
|
|
||||||
(@messages-set message-id)))
|
|
Loading…
Reference in New Issue