From 5fd7e35d998c17fabe9ee2413b9fbf8e7e6a5fd6 Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Tue, 1 Mar 2022 01:29:40 +0530 Subject: [PATCH] add remote notifications preferences (#13129) --- .../screens/notifications_settings/views.cljs | 79 +++++++++++-------- translations/en.json | 1 - 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/status_im/ui/screens/notifications_settings/views.cljs b/src/status_im/ui/screens/notifications_settings/views.cljs index 1ed7928478..a505f5f131 100644 --- a/src/status_im/ui/screens/notifications_settings/views.cljs +++ b/src/status_im/ui/screens/notifications_settings/views.cljs @@ -13,25 +13,48 @@ (defonce server (reagent/atom "")) (defn local-notifications [] - [:<> - (let [{:keys [enabled]} @(re-frame/subscribe [:notifications/wallet-transactions])] - [quo/separator {:color (:ui-02 @quo-colors/theme) - :style {:margin-vertical 8}}] - [quo/list-header (i18n/label :t/local-notifications)] - [quo/list-item - {:size :small - :title (i18n/label :t/notifications-transactions) - :accessibility-label :notifications-button - :active enabled - :on-press #(re-frame/dispatch - [::notifications/switch-transaction-notifications enabled]) - :accessory :switch}])]) + (let [{:keys [enabled]} @(re-frame/subscribe [:notifications/wallet-transactions]) + {:keys [notifications-enabled?]} @(re-frame/subscribe [:multiaccount]) + enabled (and enabled (or platform/ios? notifications-enabled?))] + [quo/list-item + {:size :small + :title (i18n/label :t/notifications-transactions) + :accessibility-label :notifications-button + :active enabled + :disabled (not (or platform/ios? notifications-enabled?)) + :on-press #(re-frame/dispatch + [::notifications/switch-transaction-notifications enabled]) + :accessory :switch}])) -(defn notifications-settings-ios [] +(defn remote-notifications [] (let [{:keys [remote-push-notifications-enabled? push-notifications-block-mentions? push-notifications-from-contacts-only?]} @(re-frame/subscribe [:multiaccount])] + [:<> + [quo/list-item + {:size :small + :title (i18n/label :t/notifications-non-contacts) + :accessibility-label :notifications-button + :active (and remote-push-notifications-enabled? + (not push-notifications-from-contacts-only?)) + :disabled (not remote-push-notifications-enabled?) + :on-press #(re-frame/dispatch + [::notifications/switch-non-contacts (not push-notifications-from-contacts-only?)]) + :accessory :switch}] + [quo/list-item + {:size :small + :title (i18n/label :t/allow-mention-notifications) + :accessibility-label :notifications-button + :active (and remote-push-notifications-enabled? + (not push-notifications-block-mentions?)) + :disabled (not remote-push-notifications-enabled?) + :on-press #(re-frame/dispatch + [::notifications/switch-block-mentions (not push-notifications-block-mentions?)]) + :accessory :switch}]])) + +(defn notifications-settings-ios [] + (let [{:keys [remote-push-notifications-enabled?]} @(re-frame/subscribe [:multiaccount])] [:<> [quo/list-item {:size :small @@ -43,25 +66,8 @@ [quo/separator {:color (:ui-02 @quo-colors/theme) :style {:margin-vertical 8}}] [quo/list-header (i18n/label :t/notifications-preferences)] - [quo/list-item - {:size :small - :title (i18n/label :t/notifications-non-contacts) - :accessibility-label :notifications-button - :active (and remote-push-notifications-enabled? - (not push-notifications-from-contacts-only?)) - :on-press #(re-frame/dispatch - [::notifications/switch-non-contacts (not push-notifications-from-contacts-only?)]) - :accessory :switch}] - [quo/list-item - {:size :small - :title (i18n/label :t/allow-mention-notifications) - :accessibility-label :notifications-button - :active (and remote-push-notifications-enabled? - (not push-notifications-block-mentions?)) - :on-press #(re-frame/dispatch - [::notifications/switch-block-mentions (not push-notifications-block-mentions?)]) - :accessory :switch}] - [local-notifications]])) + [local-notifications] + [remote-notifications]])) (defn notifications-settings-android [] (let [{:keys [notifications-enabled? remote-push-notifications-enabled?]} @@ -85,7 +91,12 @@ [::notifications/switch (not remote-push-notifications-enabled?) true]) :accessory :switch}]) - [local-notifications]])) + [quo/separator {:color (:ui-02 @quo-colors/theme) + :style {:margin-vertical 8}}] + [quo/list-header (i18n/label :t/notifications-preferences)] + [local-notifications] + (when (and platform/android? (not config/google-free)) + [remote-notifications])])) (defn notifications-settings [] [react/scroll-view {:style {:flex 1} diff --git a/translations/en.json b/translations/en.json index ecf4801a26..292d4c6b03 100644 --- a/translations/en.json +++ b/translations/en.json @@ -958,7 +958,6 @@ "notifications-switch": "Show notifications", "notifications-non-contacts": "Notifications from non-contacts", "notifications-transactions": "Wallet transactions", - "local-notifications": "Local notifications", "send-push-notifications": "Send Push Notifications", "send-push-notifications-description": "When disabled, the person receiving your messages won't be notified of their arrival", "push-notifications-server-enabled": "Server enabled",