From a3668bb48985e5997e221af2f223842795f6c434 Mon Sep 17 00:00:00 2001 From: Ulises M Date: Fri, 20 Dec 2024 17:11:47 -0600 Subject: [PATCH] Ask user to update their profile before sending a message or contact request --- src/status_im/contexts/chat/home/view.cljs | 8 ++- .../contexts/profile/contact/header/view.cljs | 61 +++++++++---------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/status_im/contexts/chat/home/view.cljs b/src/status_im/contexts/chat/home/view.cljs index 7cfa873d71..42ce25d4cd 100644 --- a/src/status_im/contexts/chat/home/view.cljs +++ b/src/status_im/contexts/chat/home/view.cljs @@ -115,13 +115,17 @@ {:scroll-input (oops/oget % "nativeEvent.contentOffset.y") :shared-value scroll-shared-value})}]))) +(defn- on-new-message-press + [] + (let [main-event [:show-bottom-sheet {:content chat.actions.view/new-chat}]] + (rf/dispatch [:profile/check-profile-update-prompt main-event]))) + (defn- banner-data [profile-link] {:title-props {:beta? true :label (i18n/label :t/messages) - :handler #(rf/dispatch - [:show-bottom-sheet {:content chat.actions.view/new-chat}]) + :handler on-new-message-press :accessibility-label :new-chat-button} :card-props {:on-press #(rf/dispatch [:open-share {:options {:url profile-link}}]) diff --git a/src/status_im/contexts/profile/contact/header/view.cljs b/src/status_im/contexts/profile/contact/header/view.cljs index e65c54db3e..2ce280a1d9 100644 --- a/src/status_im/contexts/profile/contact/header/view.cljs +++ b/src/status_im/contexts/profile/contact/header/view.cljs @@ -14,15 +14,14 @@ [utils.i18n :as i18n] [utils.re-frame :as rf])) -(defn on-contact-request +(defn on-send-contact-request [] - (rf/dispatch [:show-bottom-sheet - {:content (fn [] [contact-request/view])}])) + (let [main-event [:show-bottom-sheet {:content contact-request/view}]] + (rf/dispatch [:profile/check-profile-update-prompt main-event]))) (defn on-contact-review [] - (rf/dispatch [:show-bottom-sheet - {:content (fn [] [contact-review/view])}])) + (rf/dispatch [:show-bottom-sheet {:content contact-review/view}])) (defn view [{:keys [scroll-y]}] @@ -34,27 +33,27 @@ profile-picture (profile.utils/photo contact) online? (rf/sub [:visibility-status-updates/online? public-key]) theme (quo.theme/use-theme) - contact-status (rn/use-memo (fn [] - (cond - (= contact-request-state - constants/contact-request-state-mutual) :contact - blocked? :blocked - :else nil)) - [blocked? contact-request-state]) - on-start-chat (rn/use-callback #(rf/dispatch [:chat.ui/start-chat - public-key - ens-name]) - [ens-name public-key]) - on-unblock-press (rn/use-callback (fn [] - (rf/dispatch [:contact/unblock-contact - public-key]) - (rf/dispatch [:toasts/upsert - {:id :user-unblocked - :type :positive - :text (i18n/label :t/user-unblocked - {:username - full-name})}])) - [public-key full-name])] + contact-status (rn/use-memo + (fn [] + (cond + (= contact-request-state + constants/contact-request-state-mutual) :contact + blocked? :blocked + :else nil)) + [blocked? contact-request-state]) + on-start-chat (rn/use-callback + #(rf/dispatch [:chat.ui/start-chat public-key ens-name]) + [ens-name public-key]) + on-unblock-press (rn/use-callback + (fn [] + (rf/dispatch [:contact/unblock-contact + public-key]) + (rf/dispatch [:toasts/upsert + {:id :user-unblocked + :type :positive + :text (i18n/label :t/user-unblocked + {:username full-name})}])) + [public-key full-name])] [rn/view {:style style/header-container} [rn/view {:style style/header-top-wrapper} [rn/view {:style style/avatar-wrapper} @@ -93,14 +92,12 @@ (cond (and (not blocked?) - (or - (not contact-request-state) - (= contact-request-state constants/contact-request-state-none) - (= contact-request-state constants/contact-request-state-dismissed))) - + (or (not contact-request-state) + (= contact-request-state constants/contact-request-state-none) + (= contact-request-state constants/contact-request-state-dismissed))) [quo/button {:container-style style/button-wrapper - :on-press on-contact-request + :on-press on-send-contact-request :customization-color customization-color :icon-left :i/add-user} (i18n/label :t/send-contact-request)]