fix 1-1 Chat not removed after user is blocked (#19432)
This commit is contained in:
parent
260a741b17
commit
9bbde035dc
|
@ -53,21 +53,22 @@
|
|||
false))
|
||||
:fx [[:activity-center.notifications/fetch-unread-count]
|
||||
[:effects/push-notifications-clear-message-notifications [public-key]]
|
||||
[:dispatch [:shell/close-switcher-card public-key]]]}
|
||||
[:dispatch-later
|
||||
[{:ms 500
|
||||
:dispatch [:chat.ui/close-and-remove-chat public-key]}]]]}
|
||||
fxs)))
|
||||
|
||||
(rf/defn block-contact
|
||||
{:events [:contact.ui/block-contact-confirmed]}
|
||||
[{:keys [db] :as cofx} public-key
|
||||
{:keys [handle-navigation?]
|
||||
:or {handle-navigation? true}}]
|
||||
[{:keys [db] :as cofx} public-key]
|
||||
(let [contact (-> (contact.db/public-key->contact
|
||||
(:contacts/contacts db)
|
||||
public-key)
|
||||
(assoc :blocked? true
|
||||
:added? false
|
||||
:active? false))
|
||||
from-one-to-one-chat? (not (get-in db [:chats (:current-chat-id db) :group-chat]))]
|
||||
current-chat-id (:current-chat-id db)
|
||||
from-one-to-one-chat? (not (get-in db [:chats current-chat-id :group-chat]))]
|
||||
(rf/merge cofx
|
||||
{:db (assoc-in db [:contacts/contacts public-key] contact)}
|
||||
(contacts-store/block
|
||||
|
@ -77,7 +78,7 @@
|
|||
(re-frame/dispatch [:sanitize-messages-and-process-response block-contact])
|
||||
(re-frame/dispatch [:hide-popover])))
|
||||
;; reset navigation to avoid going back to non existing one to one chat
|
||||
(when handle-navigation?
|
||||
(when current-chat-id
|
||||
(if from-one-to-one-chat?
|
||||
(navigation/pop-to-root :shell-stack)
|
||||
(navigation/navigate-back))))))
|
||||
|
|
|
@ -134,22 +134,6 @@
|
|||
:deleted-at-clock-value last-message-clock-value})
|
||||
chats))))}))
|
||||
|
||||
(rf/defn deactivate-chat
|
||||
"Deactivate chat in db, no side effects"
|
||||
[{:keys [db now] :as cofx} chat-id]
|
||||
(rf/merge
|
||||
cofx
|
||||
{:db (-> (if (get-in db [:chats chat-id :muted])
|
||||
(assoc-in db [:chats chat-id :active] false)
|
||||
(update db :chats dissoc chat-id))
|
||||
(update :chats-home-list disj chat-id)
|
||||
(assoc :current-chat-id nil))
|
||||
:json-rpc/call [{:method "wakuext_deactivateChat"
|
||||
:params [{:id chat-id :preserveHistory true}]
|
||||
:on-success #()
|
||||
:on-error #(log/error "failed to create public chat" chat-id %)}]}
|
||||
(clear-history chat-id true)))
|
||||
|
||||
(rf/defn offload-messages
|
||||
{:events [:chat/offload-messages]}
|
||||
[{:keys [db]} chat-id]
|
||||
|
@ -175,6 +159,23 @@
|
|||
(delete-message/send-all)
|
||||
(offload-messages chat-id))))
|
||||
|
||||
(rf/defn deactivate-chat
|
||||
"Deactivate chat in db, no side effects"
|
||||
[{:keys [db now] :as cofx} chat-id]
|
||||
(rf/merge
|
||||
cofx
|
||||
{:db (-> (if (get-in db [:chats chat-id :muted])
|
||||
(assoc-in db [:chats chat-id :active] false)
|
||||
(update db :chats dissoc chat-id))
|
||||
(update :chats-home-list disj chat-id))
|
||||
:json-rpc/call [{:method "wakuext_deactivateChat"
|
||||
:params [{:id chat-id :preserveHistory true}]
|
||||
:on-success #()
|
||||
:on-error #(log/error "failed to create public chat" chat-id %)}]}
|
||||
(clear-history chat-id true)
|
||||
(when (= chat-id (:current-chat-id db))
|
||||
(close-chat))))
|
||||
|
||||
(rf/defn force-close-chat
|
||||
[{:keys [db] :as cofx} chat-id]
|
||||
(do
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
{:username
|
||||
full-name})}])
|
||||
(rf/dispatch [:contact.ui/block-contact-confirmed
|
||||
public-key
|
||||
{:handle-navigation? false}])
|
||||
public-key])
|
||||
(rf/dispatch [:contact.ui/remove-contact-pressed
|
||||
{:public-key public-key}])
|
||||
(on-close))
|
||||
|
|
Loading…
Reference in New Issue