[#12517] Ensure that all necessary contact fields are synced
This commit is contained in:
parent
68ffddbb51
commit
23a0ac9522
|
@ -35,7 +35,10 @@
|
||||||
{:events [::contact-blocked]}
|
{:events [::contact-blocked]}
|
||||||
[{:keys [db] :as cofx} {:keys [public-key]} chats]
|
[{:keys [db] :as cofx} {:keys [public-key]} chats]
|
||||||
(let [fxs (map #(clean-up-chat public-key %) chats)]
|
(let [fxs (map #(clean-up-chat public-key %) chats)]
|
||||||
(apply fx/merge cofx fxs)))
|
(apply fx/merge
|
||||||
|
cofx
|
||||||
|
{:db (update db :chats dissoc public-key)}
|
||||||
|
fxs)))
|
||||||
|
|
||||||
(fx/defn block-contact
|
(fx/defn block-contact
|
||||||
{:events [:contact.ui/block-contact-confirmed]}
|
{:events [:contact.ui/block-contact-confirmed]}
|
||||||
|
@ -51,9 +54,7 @@
|
||||||
;; add the contact to blocked contacts
|
;; add the contact to blocked contacts
|
||||||
(update :contacts/blocked (fnil conj #{}) public-key)
|
(update :contacts/blocked (fnil conj #{}) public-key)
|
||||||
;; update the contact in contacts list
|
;; update the contact in contacts list
|
||||||
(assoc-in [:contacts/contacts public-key] contact)
|
(assoc-in [:contacts/contacts public-key] contact))}
|
||||||
;; remove the 1-1 chat if it exists
|
|
||||||
(update-in [:chats] dissoc public-key))}
|
|
||||||
(contacts-store/block contact #(do (re-frame/dispatch [::contact-blocked contact (map chats-store/<-rpc %)])
|
(contacts-store/block contact #(do (re-frame/dispatch [::contact-blocked contact (map chats-store/<-rpc %)])
|
||||||
(re-frame/dispatch [:hide-popover])))
|
(re-frame/dispatch [:hide-popover])))
|
||||||
;; reset navigation to avoid going back to non existing one to one chat
|
;; reset navigation to avoid going back to non existing one to one chat
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
[status-im.utils.fx :as fx]
|
[status-im.utils.fx :as fx]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[status-im.constants :as constants]))
|
[status-im.constants :as constants]
|
||||||
|
[status-im.contact.block :as contact.block]))
|
||||||
|
|
||||||
(fx/defn load-contacts
|
(fx/defn load-contacts
|
||||||
{:events [::contacts-loaded]}
|
{:events [::contacts-loaded]}
|
||||||
|
@ -37,7 +38,7 @@
|
||||||
:address address}))
|
:address address}))
|
||||||
|
|
||||||
(fx/defn ensure-contacts
|
(fx/defn ensure-contacts
|
||||||
[{:keys [db]} contacts]
|
[{:keys [db]} contacts chats]
|
||||||
{:db (update db :contacts/contacts
|
{:db (update db :contacts/contacts
|
||||||
#(reduce (fn [acc {:keys [public-key] :as contact}]
|
#(reduce (fn [acc {:keys [public-key] :as contact}]
|
||||||
(-> acc
|
(-> acc
|
||||||
|
@ -45,10 +46,17 @@
|
||||||
(assoc-in [public-key :nickname] (:nickname contact))))
|
(assoc-in [public-key :nickname] (:nickname contact))))
|
||||||
%
|
%
|
||||||
contacts))
|
contacts))
|
||||||
:dispatch-n (map (fn [{:keys [public-key] :as contact}]
|
:dispatch-n (mapcat (fn [{:keys [public-key] :as contact}]
|
||||||
(when (contact.db/added? contact)
|
(cond-> []
|
||||||
[:start-profile-chat public-key]))
|
(contact.db/added? contact)
|
||||||
contacts)})
|
(conj [:start-profile-chat public-key])
|
||||||
|
|
||||||
|
(contact.db/removed? contact)
|
||||||
|
(conj [:offload-messages constants/timeline-chat-id])
|
||||||
|
|
||||||
|
(contact.db/blocked? contact)
|
||||||
|
(conj [::contact.block/contact-blocked contact chats])))
|
||||||
|
contacts)})
|
||||||
|
|
||||||
(fx/defn upsert-contact
|
(fx/defn upsert-contact
|
||||||
[{:keys [db] :as cofx}
|
[{:keys [db] :as cofx}
|
||||||
|
|
|
@ -79,6 +79,8 @@
|
||||||
([db public-key]
|
([db public-key]
|
||||||
(added? (get-in db [:contacts/contacts public-key]))))
|
(added? (get-in db [:contacts/contacts public-key]))))
|
||||||
|
|
||||||
|
(def removed? (complement added?))
|
||||||
|
|
||||||
(defn blocked?
|
(defn blocked?
|
||||||
([{:keys [system-tags]}]
|
([{:keys [system-tags]}]
|
||||||
(contains? system-tags :contact/blocked))
|
(contains? system-tags :contact/blocked))
|
||||||
|
|
|
@ -43,11 +43,25 @@
|
||||||
^js pin-messages (.-pinMessages response-js)
|
^js pin-messages (.-pinMessages response-js)
|
||||||
^js removed-messages (.-removedMessages response-js)
|
^js removed-messages (.-removedMessages response-js)
|
||||||
sync-handler (when-not process-async process-response)]
|
sync-handler (when-not process-async process-response)]
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
|
|
||||||
(seq chats)
|
(seq chats)
|
||||||
(do
|
(do
|
||||||
|
(when (seq contacts)
|
||||||
|
;; Note(rasom): in case if response contains contacts entries, some
|
||||||
|
;; of them might be blocked. That means we might need to recalculate
|
||||||
|
;; unviewed/mentions counters in chats where blocked users sent
|
||||||
|
;; messages. Currently we ignore unviewed/mentions values which come
|
||||||
|
;; from go side (see code few lines below) because it (probably)
|
||||||
|
;; breaks app-db state. But we still have to apply those values when
|
||||||
|
;; blocked contact is received from a paired device.
|
||||||
|
;; In order to do so, we store all affected chats separately so that
|
||||||
|
;; process loop might continue and then we use those chats on
|
||||||
|
;; processing contacts update. Currently it causes one bug: for some
|
||||||
|
;; reason own messages are counted as unviewed in 1-1 chat if they are
|
||||||
|
;; sent on paired device. Although this change reveals the bug it is
|
||||||
|
;; not the cause and thus the bug should be fixed separately.
|
||||||
|
(set! (.-chatsForContacts response-js) chats))
|
||||||
(js-delete response-js "chats")
|
(js-delete response-js "chats")
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
(process-next response-js sync-handler)
|
(process-next response-js sync-handler)
|
||||||
|
@ -78,11 +92,16 @@
|
||||||
(models.pairing/handle-installations installations-clj)))
|
(models.pairing/handle-installations installations-clj)))
|
||||||
|
|
||||||
(seq contacts)
|
(seq contacts)
|
||||||
(let [contacts-clj (types/js->clj contacts)]
|
(let [contacts-clj (types/js->clj contacts)
|
||||||
|
^js chats (.-chatsForContacts response-js)]
|
||||||
(js-delete response-js "contacts")
|
(js-delete response-js "contacts")
|
||||||
|
(js-delete response-js "chatsForContacts")
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
(process-next response-js sync-handler)
|
(process-next response-js sync-handler)
|
||||||
(models.contact/ensure-contacts (map data-store.contacts/<-rpc contacts-clj))))
|
(models.contact/ensure-contacts
|
||||||
|
(map data-store.contacts/<-rpc contacts-clj)
|
||||||
|
(when chats
|
||||||
|
(map data-store.chats/<-rpc (types/js->clj chats))))))
|
||||||
|
|
||||||
(seq communities)
|
(seq communities)
|
||||||
(let [communities-clj (types/js->clj communities)]
|
(let [communities-clj (types/js->clj communities)]
|
||||||
|
|
|
@ -40,11 +40,13 @@
|
||||||
:accessibility-label :add-to-contacts-button
|
:accessibility-label :add-to-contacts-button
|
||||||
:action #(re-frame/dispatch [:contact.ui/add-to-contact-pressed public-key])}])
|
:action #(re-frame/dispatch [:contact.ui/add-to-contact-pressed public-key])}])
|
||||||
(when platform/ios?
|
(when platform/ios?
|
||||||
[{:label (i18n/label (if muted? :t/unmute :t/mute))
|
[{:label (i18n/label (if (or muted? blocked?) :t/unmute :t/mute))
|
||||||
:icon :main-icons/notification
|
:icon :main-icons/notification
|
||||||
:accessibility-label :mute-chat
|
:accessibility-label :mute-chat
|
||||||
:selected muted?
|
:selected muted?
|
||||||
:action #(re-frame/dispatch [::chat.models/mute-chat-toggled public-key (not muted?)])}])
|
:disabled blocked?
|
||||||
|
:action (when-not blocked?
|
||||||
|
#(re-frame/dispatch [::chat.models/mute-chat-toggled public-key (not muted?)]))}])
|
||||||
[{:label (i18n/label (if blocked? :t/unblock :t/block))
|
[{:label (i18n/label (if blocked? :t/unblock :t/block))
|
||||||
:negative true
|
:negative true
|
||||||
:selected blocked?
|
:selected blocked?
|
||||||
|
@ -150,19 +152,25 @@
|
||||||
(views/letsubs [{:keys [public-key names]} [:contacts/current-contact]]
|
(views/letsubs [{:keys [public-key names]} [:contacts/current-contact]]
|
||||||
[nickname-view public-key names]))
|
[nickname-view public-key names]))
|
||||||
|
|
||||||
(defn button-item [{:keys [icon label action selected negative]}]
|
(defn button-item [{:keys [icon label action selected disabled negative]}]
|
||||||
[react/touchable-highlight {:on-press action :style {:flex 1}
|
[react/touchable-highlight {:on-press action :style {:flex 1}
|
||||||
:accessibility-label (str label "-item-button")}
|
:accessibility-label (str label "-item-button")}
|
||||||
[react/view {:flex 1 :align-items :center}
|
[react/view {:flex 1 :align-items :center}
|
||||||
[list-item/icon-column {:icon icon
|
[list-item/icon-column {:icon icon
|
||||||
:size :small
|
:size :small
|
||||||
:icon-bg-color (if negative
|
:icon-bg-color (if disabled
|
||||||
(if selected colors/red colors/red-light)
|
colors/gray-lighter
|
||||||
(if selected colors/blue colors/blue-light))
|
(if negative
|
||||||
:icon-color (if negative
|
(if selected colors/red colors/red-light)
|
||||||
(if selected colors/white colors/red)
|
(if selected colors/blue colors/blue-light)))
|
||||||
(if selected colors/white colors/blue))}]
|
:icon-color (if disabled
|
||||||
[react/text {:style {:text-align :center :color (if negative colors/red colors/blue)
|
colors/gray
|
||||||
|
(if negative
|
||||||
|
(if selected colors/white colors/red)
|
||||||
|
(if selected colors/white colors/blue)))}]
|
||||||
|
[react/text {:style {:text-align :center :color (if disabled
|
||||||
|
colors/gray
|
||||||
|
(if negative colors/red colors/blue))
|
||||||
:font-size 12 :line-height 16 :margin-top 6}
|
:font-size 12 :line-height 16 :margin-top 6}
|
||||||
:number-of-lines 2}
|
:number-of-lines 2}
|
||||||
label]]])
|
label]]])
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "v0.87.1",
|
"version": "v0.88.0",
|
||||||
"commit-sha1": "59eeed94368c1f0ee9d603e313a13f178e644514",
|
"commit-sha1": "839d6b3194e93fe29c898217549590e9f507c8e9",
|
||||||
"src-sha256": "1pnyb4vw88nx5b8np0ajhfyjblfkxr8bl40vhilz5gpz1g1a9l3c"
|
"src-sha256": "01yn1n7zh3pzdaahax5flx2alvip4rd9723nya89fmvp67qwiiy4"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue