[#13283] Fix syncing of adding contact after removal

This commit is contained in:
Roman Volosovskyi 2022-04-25 11:18:10 +02:00
parent fbfab9fd3b
commit f6f80be30a
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
5 changed files with 28 additions and 13 deletions

View File

@ -2339,6 +2339,13 @@
(fn [[contact] _]
(:added contact)))
(re-frame/reg-sub
:contacts/contact-blocked?
(fn [[_ identity] _]
[(re-frame/subscribe [:contacts/contact-by-identity identity])])
(fn [[contact] _]
(:blocked contact)))
(re-frame/reg-sub
:contacts/contact-two-names-by-identity
(fn [[_ identity] _]

View File

@ -22,7 +22,8 @@
[status-im.utils.identicon :as identicon]
[status-im.ui.components.keyboard-avoid-presentation :as kb-presentation]
[status-im.ui.components.animation :as animation]
[status-im.ui.screens.chat.photos :as photos])
[status-im.ui.screens.chat.photos :as photos]
[status-im.utils.db :as utils.db])
(:require-macros [status-im.utils.views :as views]))
(defn- render-row [row]
@ -45,19 +46,20 @@
icon])
(defn- input-icon
[state new-contact? entered-nickname]
[state new-contact? entered-nickname blocked?]
(let [icon (if new-contact? :main-icons/add :main-icons/arrow-right)]
(case state
:searching
(cond
(= state :searching)
[icon-wrapper colors/gray
[react/activity-indicator {:color colors/white-persist}]]
:valid
(and (= state :valid) (not blocked?))
[react/touchable-highlight
{:on-press #(debounce/dispatch-and-chill [:contact.ui/contact-code-submitted new-contact? entered-nickname] 3000)}
[icon-wrapper colors/blue
[icons/icon icon {:color colors/white-persist}]]]
:else
[icon-wrapper colors/gray
[icons/icon icon {:color colors/white-persist}]])))
@ -251,9 +253,12 @@
:return-key-type :done
:auto-correct false}])
(views/defview new-contact []
(views/letsubs [{:keys [state ens-name public-key error]} [:contacts/new-identity]
entered-nickname (reagent/atom "")]
(defn new-contact []
(let [{:keys [state ens-name public-key error]} @(re-frame/subscribe [:contacts/new-identity])
entered-nickname (reagent/atom "")
blocked? (and
(utils.db/valid-public-key? (or public-key ""))
@(re-frame/subscribe [:contacts/contact-blocked? public-key]))]
[react/view {:style {:flex 1}}
[topbar/topbar
{:title (i18n/label :t/new-contact)
@ -284,7 +289,7 @@
:return-key-type :go}]]
[react/view {:justify-content :center
:align-items :center}
[input-icon state true @entered-nickname]]]
[input-icon state true @entered-nickname blocked?]]]
[react/view {:min-height 30 :justify-content :flex-end :margin-bottom 16}
[quo/text {:style {:margin-horizontal 16}
:size :small

View File

@ -49,7 +49,8 @@
(i18n/label :t/group-membership-request)]]])))))
(defn add-contact-bar [public-key]
(when-not @(re-frame/subscribe [:contacts/contact-added? public-key])
(when-not (or @(re-frame/subscribe [:contacts/contact-added? public-key])
@(re-frame/subscribe [:contacts/contact-blocked? public-key]))
[react/touchable-highlight
{:on-press
#(re-frame/dispatch [:contact.ui/add-to-contact-pressed public-key])

View File

@ -37,8 +37,10 @@
:action #(re-frame/dispatch [:contact.ui/remove-contact-pressed contact])}]
[{:label (i18n/label :t/add-to-contacts)
:icon :main-icons/add-contact
:disabled blocked?
:accessibility-label :add-to-contacts-button
:action #(re-frame/dispatch [:contact.ui/add-to-contact-pressed public-key nil ens-name])}])
:action (when-not blocked?
#(re-frame/dispatch [:contact.ui/add-to-contact-pressed public-key nil ens-name]))}])
[{:label (i18n/label (if (or muted? blocked?) :t/unmute :t/mute))
:icon :main-icons/notification
:accessibility-label :mute-chat

View File

@ -4,6 +4,6 @@
"owner": "status-im",
"repo": "status-go",
"version": "v0.98.4",
"commit-sha1": "16197dc8075a6a67323d285af7593348f4289fd5",
"src-sha256": "0znmgd2qr50gyksifi7x38smz0zy3ndv54x54f2g34z9l3kilyyn"
"commit-sha1": "c531bf2ca1a32df659b0717149f541585939cb03",
"src-sha256": "018kvnfnyys6rm7fa3miqyfcarvm95bz31w2vh820jj9963c46nx"
}