[#10362] Allow receiving old messages after rejoining a pubchat
This commit is contained in:
parent
f1d070ed82
commit
6eb840c8b2
|
@ -185,12 +185,15 @@
|
|||
|
||||
(fx/defn clear-history
|
||||
"Clears history of the particular chat"
|
||||
[{:keys [db] :as cofx} chat-id]
|
||||
(let [{:keys [last-message
|
||||
[{:keys [db] :as cofx} chat-id remove-chat?]
|
||||
(let [{:keys [last-message public?
|
||||
deleted-at-clock-value]} (get-in db [:chats chat-id])
|
||||
last-message-clock-value (or (:clock-value last-message)
|
||||
deleted-at-clock-value
|
||||
(utils.clocks/send 0))]
|
||||
last-message-clock-value (if (and public? remove-chat?)
|
||||
0
|
||||
(or (:clock-value last-message)
|
||||
deleted-at-clock-value
|
||||
(utils.clocks/send 0)))]
|
||||
(println :FOOO last-message-clock-value public? remove-chat?)
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (-> db
|
||||
|
@ -217,7 +220,7 @@
|
|||
(mailserver/remove-gaps chat-id)
|
||||
(mailserver/remove-range chat-id)
|
||||
(deactivate-chat chat-id)
|
||||
(clear-history chat-id)
|
||||
(clear-history chat-id true)
|
||||
(transport.filters/stop-listening chat-id)
|
||||
(when (and navigate-home? (not (= (:view-id db) :home)))
|
||||
(navigation/navigate-to-cofx :home {}))))
|
||||
|
|
|
@ -68,16 +68,16 @@
|
|||
:chats {chat-id {:last-message {:clock-value 10}
|
||||
:unviewed-messages-count 1}}}}]
|
||||
(testing "it deletes all the messages"
|
||||
(let [actual (chat/clear-history cofx chat-id)]
|
||||
(let [actual (chat/clear-history cofx chat-id true)]
|
||||
(is (= {} (get-in actual [:db :messages chat-id])))))
|
||||
(testing "it deletes all the message groups"
|
||||
(let [actual (chat/clear-history cofx chat-id)]
|
||||
(let [actual (chat/clear-history cofx chat-id true)]
|
||||
(is (= nil (get-in actual [:db :message-lists chat-id])))))
|
||||
(testing "it deletes unviewed messages set"
|
||||
(let [actual (chat/clear-history cofx chat-id)]
|
||||
(let [actual (chat/clear-history cofx chat-id true)]
|
||||
(is (= 0 (get-in actual [:db :chats chat-id :unviewed-messages-count])))))
|
||||
(testing "it sets a deleted-at-clock-value equal to the last message clock-value"
|
||||
(let [actual (chat/clear-history cofx chat-id)]
|
||||
(let [actual (chat/clear-history cofx chat-id true)]
|
||||
(is (= 10 (get-in actual [:db :chats chat-id :deleted-at-clock-value])))))
|
||||
(testing "it does not override the deleted-at-clock-value when there are no messages"
|
||||
(let [actual (chat/clear-history (update-in cofx
|
||||
|
@ -85,7 +85,8 @@
|
|||
assoc
|
||||
:last-message nil
|
||||
:deleted-at-clock-value 100)
|
||||
chat-id)]
|
||||
chat-id
|
||||
true)]
|
||||
(is (= 100 (get-in actual [:db :chats chat-id :deleted-at-clock-value])))))
|
||||
(testing "it set the deleted-at-clock-value to now the chat has no messages nor previous deleted-at"
|
||||
(with-redefs [utils.clocks/send (constantly 42)]
|
||||
|
@ -93,10 +94,11 @@
|
|||
[:db :chats chat-id]
|
||||
assoc
|
||||
:last-message nil)
|
||||
chat-id)]
|
||||
chat-id
|
||||
true)]
|
||||
(is (= 42 (get-in actual [:db :chats chat-id :deleted-at-clock-value]))))))
|
||||
(testing "it adds the relevant rpc calls"
|
||||
(let [actual (chat/clear-history cofx chat-id)]
|
||||
(let [actual (chat/clear-history cofx chat-id true)]
|
||||
(is (::json-rpc/call actual))
|
||||
(is (= 2 (count (::json-rpc/call actual))))))))
|
||||
|
||||
|
|
|
@ -495,7 +495,7 @@
|
|||
(handlers/register-handler-fx
|
||||
:chat.ui/clear-history
|
||||
(fn [cofx [_ chat-id]]
|
||||
(chat/clear-history cofx chat-id)))
|
||||
(chat/clear-history cofx chat-id false)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:chat.ui/resend-message
|
||||
|
@ -1312,4 +1312,4 @@
|
|||
:profile
|
||||
(reset-current-profile-chat % (get-in % [:db :contacts/identity]))
|
||||
|
||||
nil))))
|
||||
nil))))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v0.63.5",
|
||||
"commit-sha1": "40e2fc7526de06b47e16fb2f89b9c329ede17fe3",
|
||||
"src-sha256": "05gwyjh3xv1gr7cp0bjgy4i82p2sa1ab4r8z64j0idq48hv0r5ny"
|
||||
"version": "v0.63.6",
|
||||
"commit-sha1": "d20cf2583f0721d809c2efe71450259c88981b4e",
|
||||
"src-sha256": "1dbiwbfw109ns4czpfqzmnll92xlqzyyc2swl693hrn67nzwymgp"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue