add remote notifications preferences (#13129)

This commit is contained in:
Parvesh Monu 2022-03-01 01:29:40 +05:30 committed by GitHub
parent a71ad6e1a8
commit 5fd7e35d99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 35 deletions

View File

@ -13,25 +13,48 @@
(defonce server (reagent/atom "")) (defonce server (reagent/atom ""))
(defn local-notifications [] (defn local-notifications []
[:<> (let [{:keys [enabled]} @(re-frame/subscribe [:notifications/wallet-transactions])
(let [{:keys [enabled]} @(re-frame/subscribe [:notifications/wallet-transactions])] {:keys [notifications-enabled?]} @(re-frame/subscribe [:multiaccount])
[quo/separator {:color (:ui-02 @quo-colors/theme) enabled (and enabled (or platform/ios? notifications-enabled?))]
:style {:margin-vertical 8}}] [quo/list-item
[quo/list-header (i18n/label :t/local-notifications)] {:size :small
[quo/list-item :title (i18n/label :t/notifications-transactions)
{:size :small :accessibility-label :notifications-button
:title (i18n/label :t/notifications-transactions) :active enabled
:accessibility-label :notifications-button :disabled (not (or platform/ios? notifications-enabled?))
:active enabled :on-press #(re-frame/dispatch
:on-press #(re-frame/dispatch [::notifications/switch-transaction-notifications enabled])
[::notifications/switch-transaction-notifications enabled]) :accessory :switch}]))
:accessory :switch}])])
(defn notifications-settings-ios [] (defn remote-notifications []
(let [{:keys [remote-push-notifications-enabled? (let [{:keys [remote-push-notifications-enabled?
push-notifications-block-mentions? push-notifications-block-mentions?
push-notifications-from-contacts-only?]} push-notifications-from-contacts-only?]}
@(re-frame/subscribe [:multiaccount])] @(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 [quo/list-item
{:size :small {:size :small
@ -43,25 +66,8 @@
[quo/separator {:color (:ui-02 @quo-colors/theme) [quo/separator {:color (:ui-02 @quo-colors/theme)
:style {:margin-vertical 8}}] :style {:margin-vertical 8}}]
[quo/list-header (i18n/label :t/notifications-preferences)] [quo/list-header (i18n/label :t/notifications-preferences)]
[quo/list-item [local-notifications]
{:size :small [remote-notifications]]))
: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]]))
(defn notifications-settings-android [] (defn notifications-settings-android []
(let [{:keys [notifications-enabled? remote-push-notifications-enabled?]} (let [{:keys [notifications-enabled? remote-push-notifications-enabled?]}
@ -85,7 +91,12 @@
[::notifications/switch [::notifications/switch
(not remote-push-notifications-enabled?) true]) (not remote-push-notifications-enabled?) true])
:accessory :switch}]) :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 [] (defn notifications-settings []
[react/scroll-view {:style {:flex 1} [react/scroll-view {:style {:flex 1}

View File

@ -958,7 +958,6 @@
"notifications-switch": "Show notifications", "notifications-switch": "Show notifications",
"notifications-non-contacts": "Notifications from non-contacts", "notifications-non-contacts": "Notifications from non-contacts",
"notifications-transactions": "Wallet transactions", "notifications-transactions": "Wallet transactions",
"local-notifications": "Local notifications",
"send-push-notifications": "Send Push 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", "send-push-notifications-description": "When disabled, the person receiving your messages won't be notified of their arrival",
"push-notifications-server-enabled": "Server enabled", "push-notifications-server-enabled": "Server enabled",