Skip to content

Commit

Permalink
[#7933] fix - joining public chat with messages throws error
Browse files Browse the repository at this point in the history
[#7933] fix - joining public chat with messages throws error
  • Loading branch information
bitsikka authored and rasom committed Apr 19, 2019
1 parent a4b5f69 commit 8482ea5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions src/status_im/chat/models.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]}]
Expand Down
4 changes: 2 additions & 2 deletions src/status_im/chat/models/message.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions src/status_im/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8482ea5

Please sign in to comment.