[#7933] fix - joining public chat with messages throws error

[#7933] fix - joining public chat with messages throws error
This commit is contained in:
bitsikka 2019-04-08 20:15:59 +05:45 committed by Roman Volosovskyi
parent a4b5f69e5b
commit 8482ea5b5a
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
3 changed files with 12 additions and 11 deletions

View File

@ -56,7 +56,7 @@
[{:keys [current-chat-id] :as db} ui-element]
(update-in db [:chat-ui-props current-chat-id ui-element] not))
(defn join-time-messages-checked
(fx/defn join-time-messages-checked
"The key :might-have-join-time-messages? in public chats signals that
the public chat is freshly (re)created and requests for messages to the
mailserver for the topic has not completed yet. Likewise, the key
@ -65,12 +65,13 @@
by mailserver, corresponding event :chat.ui/join-time-messages-checked
dissociates these two fileds via this function, thereby signalling that the
public chat is not fresh anymore."
[{:keys [chats] :as db} chat-id]
(if (:might-have-join-time-messages? (get chats chat-id))
(-> db
(update-in [:chats chat-id] dissoc :join-time-mail-request-id)
(update-in [:chats chat-id] dissoc :might-have-join-time-messages?))
db))
[{:keys [db] :as cofx} chat-id]
(when (:might-have-join-time-messages? (get-chat cofx chat-id))
{:db (update-in db
[:chats chat-id]
dissoc
:join-time-mail-request-id
:might-have-join-time-messages?)}))
(defn- create-new-chat
[chat-id {:keys [db now]}]

View File

@ -289,9 +289,9 @@
(map (partial update-last-message (:chats db)) chat-ids)))
(fx/defn declare-syncd-public-chats!
[{:keys [db] :as cofx} chat-ids]
[cofx chat-ids]
(apply fx/merge cofx
(map (partial chat-model/join-time-messages-checked db) chat-ids)))
(map (partial chat-model/join-time-messages-checked cofx) chat-ids)))
(defn- chat-ids->never-synced-public-chat-ids [chats chat-ids]
(let [never-synced-public-chat-ids (mailserver/chats->never-synced-public-chats chats)]

View File

@ -753,8 +753,8 @@
(handlers/register-handler-fx
:chat.ui/join-time-messages-checked
(fn [{:keys [db]} [_ chat-id]]
{:db (chat/join-time-messages-checked db chat-id)}))
(fn [cofx [_ chat-id]]
(chat/join-time-messages-checked cofx chat-id)))
(handlers/register-handler-fx
:chat.ui/show-message-details