Skip to content

Commit

Permalink
chore: Settings cleanup due changes coming on a separated PR
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoufer committed Jul 18, 2024
1 parent 9cddf33 commit a4befbe
Showing 1 changed file with 2 additions and 46 deletions.
48 changes: 2 additions & 46 deletions app/components/Views/Settings/NotificationsSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable react/display-name */
import React, { FC, useEffect } from 'react';
import { Pressable, ScrollView, Switch, View } from 'react-native';
import { useSelector, useDispatch } from 'react-redux';
import { useSelector } from 'react-redux';
import { camelCase } from 'lodash';

import { strings } from '../../../../../locales/i18n';
Expand All @@ -25,11 +25,9 @@ import {
} from './NotificationsSettings.constants';

import {
notificationSettings as defaultDisabledNotificationSettings,
mmStorage,
requestPushNotificationsPermission,
} from '../../../../util/notifications';
import { updateNotificationStatus } from '../../../../actions/notification';
import { STORAGE_IDS } from '../../../../util/notifications/settings/storage/constants';
import Routes from '../../../../constants/navigation/Routes';
import { IconName } from '../../../../component-library/components/Icons/Icon';
Expand Down Expand Up @@ -72,7 +70,6 @@ const NotificationsSettings = ({ navigation, route }: Props) => {

const isNotificationEnabled = notificationsSettingsState?.isEnabled;

const dispatch = useDispatch();
const { accounts } = useAccounts();

// TODO: Replace "any" with type
Expand All @@ -84,15 +81,7 @@ const NotificationsSettings = ({ navigation, route }: Props) => {
);

const toggleNotificationsEnabled = () => {
!isNotificationEnabled
? requestPushNotificationsPermission()
: dispatch(
updateNotificationStatus({
isEnabled: false,
notificationsOpts: defaultDisabledNotificationSettings,
accounts: [],
}),
);
!isNotificationEnabled && requestPushNotificationsPermission();
};

const isFullScreenModal = route?.params?.isFullScreenModal;
Expand Down Expand Up @@ -120,17 +109,6 @@ const NotificationsSettings = ({ navigation, route }: Props) => {
null,
),
);
dispatch(
updateNotificationStatus({
...notificationsSettingsState,
accounts:
notificationsSettingsState?.accounts ??
accounts.reduce((acc: { [key: string]: boolean }, account) => {
acc[account.address] = true;
return acc;
}, {}),
}),
);
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[colors],
Expand Down Expand Up @@ -192,17 +170,6 @@ const NotificationsSettings = ({ navigation, route }: Props) => {
camelCase(opt.title)
]
}
onOptionUpdated={(value) => {
dispatch(
updateNotificationStatus({
...notificationsSettingsState,
notificationsOpts: {
...notificationsSettingsState.notificationsOpts,
[camelCase(opt.title)]: value,
},
}),
);
}}
testId={NotificationsViewSelectorsIDs[opt.title]}
disabled={opt.disabled}
/>
Expand All @@ -226,17 +193,6 @@ const NotificationsSettings = ({ navigation, route }: Props) => {
value={
notificationsSettingsState?.accounts[account.address] ?? true
}
onOptionUpdated={(value) => {
dispatch(
updateNotificationStatus({
...notificationsSettingsState,
accounts: {
...notificationsSettingsState.accounts,
[account.address]: value,
},
}),
);
}}
/>
))}
</>
Expand Down

0 comments on commit a4befbe

Please sign in to comment.