[#12684] Messages disappear from Timeline if join public chat and open Timeline tab while public chat history is loading
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
a9333ad52c
commit
8d0bdf7c7f
|
@ -187,10 +187,12 @@
|
|||
(fx/defn offload-messages
|
||||
{:events [:offload-messages]}
|
||||
[{:keys [db]} chat-id]
|
||||
{:db (-> db
|
||||
(update :messages dissoc chat-id)
|
||||
(update :message-lists dissoc chat-id)
|
||||
(update :pagination-info dissoc chat-id))})
|
||||
(merge {:db (-> db
|
||||
(update :messages dissoc chat-id)
|
||||
(update :message-lists dissoc chat-id)
|
||||
(update :pagination-info dissoc chat-id))}
|
||||
(when (and (= chat-id constants/timeline-chat-id) (= (:view-id db) :status))
|
||||
{:dispatch [:init-timeline-chat]})))
|
||||
|
||||
(fx/defn close-chat
|
||||
{:events [:close-chat]}
|
||||
|
|
|
@ -39,27 +39,37 @@
|
|||
|
||||
(fx/defn ensure-contacts
|
||||
[{:keys [db]} contacts chats]
|
||||
{:db (update db :contacts/contacts
|
||||
#(reduce (fn [acc {:keys [public-key] :as contact}]
|
||||
(-> acc
|
||||
(update public-key merge contact)
|
||||
(assoc-in [public-key :nickname] (:nickname contact))))
|
||||
%
|
||||
contacts))
|
||||
:dispatch-n (mapcat (fn [{:keys [public-key] :as contact}]
|
||||
(cond-> []
|
||||
(:added contact)
|
||||
(conj [:start-profile-chat public-key])
|
||||
(let [events
|
||||
(reduce
|
||||
(fn [acc {:keys [public-key] :as contact}]
|
||||
(let [added (:added contact)
|
||||
was-added (contact.db/added? db public-key)
|
||||
blocked (:blocked contact)
|
||||
was-blocked (contact.db/blocked? db public-key)]
|
||||
(cond-> acc
|
||||
(and added (not was-added))
|
||||
(conj [:start-profile-chat public-key])
|
||||
|
||||
(not (:added contact))
|
||||
(conj [:offload-messages constants/timeline-chat-id])
|
||||
(and was-added (not added))
|
||||
(conj nil)
|
||||
|
||||
(:blocked contact)
|
||||
(conj [::contact.block/contact-blocked contact chats])
|
||||
(and blocked (not was-blocked))
|
||||
(conj [::contact.block/contact-blocked contact chats])
|
||||
|
||||
(contact.db/blocked? db public-key)
|
||||
(conj [::contact.block/contact-unblocked public-key])))
|
||||
contacts)})
|
||||
(and was-blocked (not blocked))
|
||||
(conj [::contact.block/contact-unblocked public-key]))))
|
||||
[[:offload-messages constants/timeline-chat-id]]
|
||||
contacts)]
|
||||
(merge
|
||||
{:db (update db :contacts/contacts
|
||||
#(reduce (fn [acc {:keys [public-key] :as contact}]
|
||||
(-> acc
|
||||
(update public-key merge contact)
|
||||
(assoc-in [public-key :nickname] (:nickname contact))))
|
||||
%
|
||||
contacts))}
|
||||
(when (> (count events) 1)
|
||||
{:dispatch-n events}))))
|
||||
|
||||
(fx/defn upsert-contact
|
||||
[{:keys [db] :as cofx}
|
||||
|
|
|
@ -73,8 +73,8 @@
|
|||
(get-in db [:contacts/contacts public-key]))
|
||||
|
||||
(defn added?
|
||||
([{:keys [system-tags]}]
|
||||
(contains? system-tags :contact/added))
|
||||
([contact]
|
||||
(:added contact))
|
||||
([db public-key]
|
||||
(added? (get-in db [:contacts/contacts public-key]))))
|
||||
|
||||
|
@ -84,29 +84,6 @@
|
|||
([db public-key]
|
||||
(blocked? (get-in db [:contacts/contacts public-key]))))
|
||||
|
||||
(defn pending?
|
||||
"Check if this is a pending? contact, meaning one side sent a contact request
|
||||
but the other didn't respond to it yet"
|
||||
([{:keys [system-tags] :as contact}]
|
||||
(let [request-received? (contains? system-tags :contact/request-received)
|
||||
added? (added? contact)]
|
||||
(and (or request-received?
|
||||
added?)
|
||||
(not (and request-received? added?)))))
|
||||
([db public-key]
|
||||
(pending? (get-in db [:contacts/contacts public-key]))))
|
||||
|
||||
(defn legacy-pending?
|
||||
"Would the :pending? field be true? for contacts sync payload sent to devices
|
||||
running 0.11.0 or older?"
|
||||
([{:keys [system-tags] :as contact}]
|
||||
(let [request-received? (contains? system-tags :contact/request-received)
|
||||
added? (added? contact)]
|
||||
(and request-received?
|
||||
(not added?))))
|
||||
([db public-key]
|
||||
(pending? (get-in db [:contacts/contacts public-key]))))
|
||||
|
||||
(defn active?
|
||||
"Checks that the user is added to the contact and not blocked"
|
||||
([contact]
|
||||
|
|
Loading…
Reference in New Issue