[#6307] fix each message sent before upgrade is shown twice after upgrade from 0.9.29
This commit is contained in:
parent
2a292e96e5
commit
99162fa971
|
@ -145,10 +145,13 @@
|
||||||
(chat-loading/group-chat-messages chat-id (get chat->message chat-id))))
|
(chat-loading/group-chat-messages chat-id (get chat->message chat-id))))
|
||||||
|
|
||||||
(defn- add-to-chat?
|
(defn- add-to-chat?
|
||||||
[{:keys [db]} {:keys [chat-id clock-value message-id] :as message}]
|
[{:keys [db]} {:keys [chat-id clock-value message-id message-id-old-format] :as message}]
|
||||||
(let [{:keys [deleted-at-clock-value messages not-loaded-message-ids]}
|
(let [{:keys [deleted-at-clock-value messages not-loaded-message-ids]}
|
||||||
(get-in db [:chats chat-id])]
|
(get-in db [:chats chat-id])]
|
||||||
(not (or (get messages message-id)
|
(not (or (get messages message-id)
|
||||||
|
;; TODO(rasom): remove this condition
|
||||||
|
;; on when 0.9.29 will not be available for users
|
||||||
|
(and message-id-old-format (get messages message-id-old-format))
|
||||||
(get not-loaded-message-ids message-id)
|
(get not-loaded-message-ids message-id)
|
||||||
(>= deleted-at-clock-value clock-value)))))
|
(>= deleted-at-clock-value clock-value)))))
|
||||||
|
|
||||||
|
|
|
@ -105,13 +105,18 @@
|
||||||
this)
|
this)
|
||||||
(send-with-pubkey cofx params)))))
|
(send-with-pubkey cofx params)))))
|
||||||
(receive [this chat-id signature _ cofx]
|
(receive [this chat-id signature _ cofx]
|
||||||
{:chat-received-message/add-fx
|
(let [old-message (Message. (:text content) content-type message-type
|
||||||
[(assoc (into {} this)
|
clock-value timestamp)]
|
||||||
:message-id (transport.utils/message-id this)
|
{:chat-received-message/add-fx
|
||||||
:show? true
|
[(assoc (into {} this)
|
||||||
:chat-id chat-id
|
:message-id (transport.utils/message-id this)
|
||||||
:from signature
|
;; TODO(rasom): remove this condition
|
||||||
:js-obj (:js-obj cofx))]})
|
;; on when 0.9.29 will not be available for users
|
||||||
|
:message-id-old-format (transport.utils/message-id-old-format old-message)
|
||||||
|
:show? true
|
||||||
|
:chat-id chat-id
|
||||||
|
:from signature
|
||||||
|
:js-obj (:js-obj cofx))]}))
|
||||||
(validate [this]
|
(validate [this]
|
||||||
(if (spec/valid? :message/message this)
|
(if (spec/valid? :message/message this)
|
||||||
this
|
this
|
||||||
|
|
|
@ -22,6 +22,15 @@
|
||||||
[message]
|
[message]
|
||||||
(sha3 (pr-str message)))
|
(sha3 (pr-str message)))
|
||||||
|
|
||||||
|
(defn message-id-old-format
|
||||||
|
"Get an old format message-id.
|
||||||
|
To be removed on 8th day after 0.9.30"
|
||||||
|
[message]
|
||||||
|
(-> message
|
||||||
|
pr-str
|
||||||
|
(clojure.string/replace "message.protocol" "message.v1.protocol")
|
||||||
|
sha3))
|
||||||
|
|
||||||
(defn get-topic
|
(defn get-topic
|
||||||
"Get the topic of a group chat or public chat from the chat-id"
|
"Get the topic of a group chat or public chat from the chat-id"
|
||||||
[chat-id]
|
[chat-id]
|
||||||
|
|
Loading…
Reference in New Issue