Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#21571] ask user to update their profile #21862

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/quo/components/colors/color/style.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
selected? (assoc :border-top-color (colors/alpha color 0.4)
:border-end-color (colors/alpha color 0.4)
:border-bottom-color (colors/alpha color 0.2)
:border-start-color (colors/alpha color 0.2))
:border-start-color (colors/alpha color 0.2)
:border-color nil)
ulisesmac marked this conversation as resolved.
Show resolved Hide resolved
(zero? idx) (assoc :margin-left -4))))

(defn color-circle
Expand Down
12 changes: 6 additions & 6 deletions src/quo/components/drawers/bottom_actions/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
[:scroll? {:optional true} [:maybe :boolean]]
[:blur? {:optional true} [:maybe :boolean]]
[:container-style {:optional true} [:maybe :map]]
[:buttons-container-style {:optional true} [:maybe :map]]]]]
[:buttons-container-style {:optional true} [:maybe :map]]
[:buttons-style {:optional true} [:maybe :map]]]]]
:any])

(def ^:private role-icon
Expand All @@ -43,10 +44,9 @@
(defn- view-internal
[{:keys [actions description description-text description-top-text error-message role button-one-label
button-two-label blur? button-one-props button-two-props scroll? container-style
buttons-container-style context-tag-props]}]
buttons-container-style buttons-style context-tag-props]}]
(let [theme (quo.theme/use-theme)]
[rn/view
{:style (merge (style/container scroll? blur? theme) container-style)}
[rn/view {:style (merge (style/container scroll? blur? theme) container-style)}
(when (= description :top-error)
[rn/view {:style style/error-message}
[icon/icon
Expand Down Expand Up @@ -82,7 +82,7 @@
[button/button
(merge
{:size 40
:container-style style/button-container
:container-style (merge style/button-container buttons-style)
:background (when (or blur? scroll?) :blur)
ulisesmac marked this conversation as resolved.
Show resolved Hide resolved
:theme theme
:accessibility-label :button-two}
Expand All @@ -91,7 +91,7 @@
[button/button
(merge
{:size 40
:container-style style/button-container
:container-style (merge style/button-container buttons-style)
:background (when (or blur? scroll?) :blur)
:theme theme
:accessibility-label :button-one}
Expand Down
6 changes: 3 additions & 3 deletions src/status_im/common/home/banner/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
[{:keys [scroll-ref tabs selected-tab on-tab-change scroll-shared-value content customization-color]}]
(let [theme (quo.theme/use-theme)]
[:<>
[:f> banner-card-blur-layer scroll-shared-value
[:f> banner-card-hiding-layer
[banner-card-blur-layer scroll-shared-value
[banner-card-hiding-layer
(assoc content :scroll-shared-value scroll-shared-value :theme theme)]]
[:f> banner-card-tabs-layer
[banner-card-tabs-layer
{:scroll-shared-value scroll-shared-value
:selected-tab selected-tab
:tabs tabs
Expand Down
8 changes: 6 additions & 2 deletions src/status_im/contexts/chat/home/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,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])))

ulisesmac marked this conversation as resolved.
Show resolved Hide resolved
(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}}])
Expand Down
61 changes: 29 additions & 32 deletions src/status_im/contexts/profile/contact/header/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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])))
ulisesmac marked this conversation as resolved.
Show resolved Hide resolved

(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]}]
Expand All @@ -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 []
ulisesmac marked this conversation as resolved.
Show resolved Hide resolved
(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}
Expand Down Expand Up @@ -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)]
Expand Down
28 changes: 18 additions & 10 deletions src/status_im/contexts/profile/edit/accent_colour/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,35 @@
[utils.re-frame :as rf]))

(rf/reg-event-fx :profile/edit-accent-colour-success
(fn [_ [customization-color]]
(fn [_ [{:keys [customization-color navigate-back? show-toast?]}]]
{:fx [[:dispatch [:profile/save-local-accent-color customization-color]]
[:dispatch [:navigate-back]]
[:dispatch
[:toasts/upsert
{:type :positive
:theme :dark
:text (i18n/label :t/accent-colour-updated)}]]]}))
(when navigate-back?
[:dispatch [:navigate-back]])
(when show-toast?
[:dispatch
[:toasts/upsert
{:type :positive
:theme :dark
:text (i18n/label :t/accent-colour-updated)}]])]}))

(rf/reg-event-fx :profile/save-local-accent-color
(fn [{:keys [db]} [customization-color]]
{:db (assoc-in db [:profile/profile :customization-color] customization-color)}))

(defn edit-accent-colour
[{:keys [db]} [customization-color]]
[{:keys [db]}
[{:keys [color navigate-back? show-toast?]
:or {navigate-back? true
show-toast? true}}]]
(let [key-uid (get-in db [:profile/profile :key-uid])]
{:fx [[:json-rpc/call
[{:method "wakuext_setCustomizationColor"
:params [{:customizationColor customization-color
:params [{:customizationColor color
:keyUid key-uid}]
:on-success [:profile/edit-accent-colour-success customization-color]
:on-success [:profile/edit-accent-colour-success
{:customization-color color
:navigate-back? navigate-back?
:show-toast? show-toast?}]
:on-error #(log/error "failed to edit accent color." {:error %})}]]]}))

(rf/reg-event-fx :profile/edit-accent-colour edit-accent-colour)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
[{:method "wakuext_setCustomizationColor"
:params [{:customizationColor new-color
:keyUid key-uid}]
:on-success [:profile/edit-accent-colour-success new-color]
:on-success [:profile/edit-accent-colour-success
{:customization-color new-color
:navigate-back? true
:show-toast? true}]
:on-error fn?}]]]}]
(is (match? expected
(sut/edit-accent-colour cofx [new-color])))))
(sut/edit-accent-colour cofx [{:color new-color}])))))
3 changes: 2 additions & 1 deletion src/status_im/contexts/profile/edit/accent_colour/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
{:type :primary
:customization-color @unsaved-custom-color
:on-press (fn []
(rf/dispatch [:profile/edit-accent-colour @unsaved-custom-color]))}
(rf/dispatch [:profile/edit-accent-colour
{:color @unsaved-custom-color}]))}
(i18n/label :t/save-colour)]]]]))))

(defn view
Expand Down
44 changes: 25 additions & 19 deletions src/status_im/contexts/profile/edit/header/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,51 @@
(update db :profile/profile dissoc :images))}))

(rf/reg-event-fx :profile/edit-profile-picture-success
(fn [_ [images]]
(let [has-picture? (rf/sub [:profile/has-picture])]
(fn [{db :db} [{:keys [show-toast?]} images]]
(let [has-picture? (-> db :profile/profile :images count pos?)]
{:fx [[:dispatch [:profile/update-local-picture (reverse images)]]
[:dispatch
[:toasts/upsert
{:type :positive
:theme :dark
:text (i18n/label (if has-picture?
:t/profile-picture-updated
:t/profile-picture-added))}]]]})))
(when show-toast?
[:dispatch
[:toasts/upsert
{:type :positive
:theme :dark
:text (i18n/label (if has-picture?
:t/profile-picture-updated
:t/profile-picture-added))}]])]})))

(defn edit-profile-picture
[{:keys [db]} [picture crop-width crop-height]]
[{:keys [db]}
[{:keys [picture crop-width crop-height show-toast?]
:or {show-toast? true}}]]
(let [key-uid (get-in db [:profile/profile :key-uid])
crop-width (or crop-width profile-picture-picker/crop-size)
crop-height (or crop-height profile-picture-picker/crop-size)
path (string/replace-first picture #"file://" "")]
{:fx [[:json-rpc/call
[{:method "multiaccounts_storeIdentityImage"
:params [key-uid path 0 0 crop-width crop-height]
:on-success [:profile/edit-profile-picture-success]}]]]}))
:on-success [:profile/edit-profile-picture-success {:show-toast? show-toast?}]}]]]}))

(rf/reg-event-fx :profile/edit-picture edit-profile-picture)

(rf/reg-event-fx :profile/delete-profile-picture-success
(fn [_]
(fn [_ [{:keys [show-toast?]}]]
{:fx [[:dispatch [:profile/update-local-picture nil]]
[:dispatch
[:toasts/upsert
{:type :positive
:theme :dark
:text (i18n/label :t/profile-picture-removed)}]]]}))
(when show-toast?
[:dispatch
[:toasts/upsert
{:type :positive
:theme :dark
:text (i18n/label :t/profile-picture-removed)}]])]}))

(defn delete-profile-picture
[{:keys [db]}]
[{:keys [db]}
[{:keys [show-toast?]
:or {show-toast? true}}]]
(let [key-uid (get-in db [:profile/profile :key-uid])]
{:fx [[:json-rpc/call
[{:method "multiaccounts_deleteIdentityImage"
:params [key-uid]
:on-success [:profile/delete-profile-picture-success]}]]]}))
:on-success [:profile/delete-profile-picture-success {:show-toast? show-toast?}]}]]]}))

(rf/reg-event-fx :profile/delete-picture delete-profile-picture)
8 changes: 4 additions & 4 deletions src/status_im/contexts/profile/edit/header/events_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
[{:method "multiaccounts_storeIdentityImage"
:params [key-uid picture 0 0 profile-picture-picker/crop-size
profile-picture-picker/crop-size]
:on-success [:profile/edit-profile-picture-success]}]]]}]
:on-success [:profile/edit-profile-picture-success {:show-toast? true}]}]]]}]
(is (match? expected
(sut/edit-profile-picture cofx [picture])))))
(sut/edit-profile-picture cofx [{:picture picture}])))))

(deftest delete-picture-test
(let [key-uid "key-uid"
cofx {:db {:profile/profile {:key-uid key-uid}}}
expected {:fx [[:json-rpc/call
[{:method "multiaccounts_deleteIdentityImage"
:params [key-uid]
:on-success [:profile/delete-profile-picture-success]}]]]}]
:on-success [:profile/delete-profile-picture-success {:show-toast? true}]}]]]}]
(is (match? expected
(sut/delete-profile-picture cofx)))))
(sut/delete-profile-picture cofx [{}])))))
2 changes: 1 addition & 1 deletion src/status_im/contexts/profile/edit/header/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
has-picture? (rf/sub [:profile/has-picture])
on-change-profile-pic (fn [picture]
(if picture
(rf/dispatch [:profile/edit-picture picture])
(rf/dispatch [:profile/edit-picture {:picture picture}])
(rf/dispatch [:profile/delete-picture])))]
[rn/view
{:key :edit-profile
Expand Down
33 changes: 33 additions & 0 deletions src/status_im/contexts/profile/edit/introduce_yourself/view.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(ns status-im.contexts.profile.edit.introduce-yourself.view
ulisesmac marked this conversation as resolved.
Show resolved Hide resolved
(:require [quo.core :as quo]
[react-native.core :as rn]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

(defn sheet
[{:keys [pending-event]}]
(let [on-accept (fn []
(rf/dispatch [:open-modal :screen/profile.edit-profile-modal
{:pending-event pending-event}]))
on-reject #(rf/dispatch pending-event)]
[:<>
[rn/view {:style {:padding-horizontal 20}}
[quo/text
{:style {:padding-bottom 4}
:size :heading-2
:weight :semi-bold}
(i18n/label :t/just-introduce-yourself)]
[quo/text
{:style {:padding-top 4 :padding-bottom 12}
:size :paragraph-1
:weight :regular}
(i18n/label :t/add-display-name-and-picture)]]
[quo/bottom-actions
{:actions :two-actions
:buttons-style {:flex-shrink 1 :flex-basis 0}
:button-one-label (i18n/label :t/edit-profile)
:button-one-props {:type :primary
:on-press on-accept}
:button-two-label (i18n/label :t/skip)
:button-two-props {:type :grey
:on-press on-reject}}]]))
Loading