Skip to content

Commit

Permalink
refactor function usage
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoufer committed Aug 16, 2024
1 parent 32d53c0 commit 6d498e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 7 additions & 3 deletions app/components/Views/Settings/NotificationsSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import { NotificationsToggleTypes } from './NotificationsSettings.constants';

import { selectIsMetamaskNotificationsEnabled } from '../../../../selectors/notifications';

import { requestPushNotificationsPermission } from '../../../../util/notifications';
import {
requestPushNotificationsPermission,
asyncAlert,
} from '../../../../util/notifications';
import Routes from '../../../../constants/navigation/Routes';
import { IconName } from '../../../../component-library/components/Icons/Icon';
import ButtonIcon, {
Expand Down Expand Up @@ -83,8 +86,9 @@ const NotificationsSettings = ({ navigation, route }: Props) => {

const toggleNotificationsEnabled = async () => {
if (!isMetamaskNotificationsEnabled) {
const nativeNotificationStatus =
await requestPushNotificationsPermission();
const nativeNotificationStatus = await requestPushNotificationsPermission(
asyncAlert,
);

if (nativeNotificationStatus) {
await enableNotifications();
Expand Down
9 changes: 5 additions & 4 deletions app/core/NotificationManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
NotificationTransactionTypes,
isNotificationsFeatureEnabled,
requestPushNotificationsPermission,
asyncAlert,
} from '../util/notifications';
import { safeToChecksumAddress } from '../util/address';
import ReviewManager from './ReviewManager';
Expand Down Expand Up @@ -253,7 +254,7 @@ class NotificationManager {

Device.isIos() &&
setTimeout(() => {
requestPushNotificationsPermission();
requestPushNotificationsPermission(asyncAlert);
}, 5000);

// Prompt review
Expand Down Expand Up @@ -428,9 +429,9 @@ class NotificationManager {
.filter(
(tx) =>
safeToChecksumAddress(tx.txParams?.to) ===
selectedInternalAccountChecksummedAddress &&
selectedInternalAccountChecksummedAddress &&

Check failure on line 432 in app/core/NotificationManager.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

Insert `··`
safeToChecksumAddress(tx.txParams?.from) !==
selectedInternalAccountChecksummedAddress &&
selectedInternalAccountChecksummedAddress &&

Check failure on line 434 in app/core/NotificationManager.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

Insert `··`
tx.chainId === chainId &&
tx.status === 'confirmed' &&
lastBlock <= parseInt(tx.blockNumber, 10) &&
Expand Down Expand Up @@ -487,7 +488,7 @@ export default {
return instance?.gotIncomingTransaction(lastBlock);
},
requestPushNotificationsPermission() {
return instance?.requestPushNotificationsPermission();
return instance?.requestPushNotificationsPermission(asyncAlert);
},
showSimpleNotification(data) {
return instance?.showSimpleNotification(data);
Expand Down

0 comments on commit 6d498e1

Please sign in to comment.