From 74ea1ffead9b0e5b15921fe17ab399ec70a4b437 Mon Sep 17 00:00:00 2001 From: Michal Date: Wed, 30 Oct 2024 15:30:57 +0000 Subject: [PATCH] Fix key --- .../Notifications/useCases/common/notifications.ts | 9 +++++++++ .../useCases/common/rewards-updated-notification.ts | 3 ++- .../useCases/common/transaction-received-notification.ts | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/wallet-mobile/src/features/Notifications/useCases/common/notifications.ts b/apps/wallet-mobile/src/features/Notifications/useCases/common/notifications.ts index 11356dba56..2a12e26505 100644 --- a/apps/wallet-mobile/src/features/Notifications/useCases/common/notifications.ts +++ b/apps/wallet-mobile/src/features/Notifications/useCases/common/notifications.ts @@ -1,6 +1,7 @@ import {Notification, Notifications} from '@jamsinclair/react-native-notifications' import {mountAsyncStorage} from '@yoroi/common' import {Notifications as NotificationTypes} from '@yoroi/types' +import {NotificationTrigger} from '@yoroi/types/lib/typescript/notifications/manager' import {formatCurrency, getCurrencySymbol} from '../../../Settings/useCases/changeAppSettings/Currency/CurrencyContext' @@ -36,6 +37,14 @@ export const displayNotificationEvent = async (notificationEvent: NotificationTy id: notificationEvent.id, }) } + + if (notificationEvent.trigger === NotificationTrigger.RewardsUpdated) { + sendNotification({ + title: 'Rewards updated', + body: 'Your rewards have been updated', + id: notificationEvent.id, + }) + } } const sendNotification = (options: {title: string; body: string; id: number}) => { diff --git a/apps/wallet-mobile/src/features/Notifications/useCases/common/rewards-updated-notification.ts b/apps/wallet-mobile/src/features/Notifications/useCases/common/rewards-updated-notification.ts index 5e71cb6a03..b4d58eaa34 100644 --- a/apps/wallet-mobile/src/features/Notifications/useCases/common/rewards-updated-notification.ts +++ b/apps/wallet-mobile/src/features/Notifications/useCases/common/rewards-updated-notification.ts @@ -45,7 +45,8 @@ const buildNotifications = async (appStorage: App.Storage) => { const wallet = walletManager.getWalletById(walletId) if (!wallet) continue - const storage = buildProcessedNotificationsStorage(appStorage.join(`wallet/${walletId}/${storageKey}/`)) + const fullStorageKey = `wallet/${walletId}/${wallet.networkManager.network}/${storageKey}/` as const + const storage = buildProcessedNotificationsStorage(appStorage.join(fullStorageKey)) const stakingInfo = await wallet.getStakingInfo() if (stakingInfo.status !== 'staked') continue diff --git a/apps/wallet-mobile/src/features/Notifications/useCases/common/transaction-received-notification.ts b/apps/wallet-mobile/src/features/Notifications/useCases/common/transaction-received-notification.ts index dcd4bab540..08bc87a206 100644 --- a/apps/wallet-mobile/src/features/Notifications/useCases/common/transaction-received-notification.ts +++ b/apps/wallet-mobile/src/features/Notifications/useCases/common/transaction-received-notification.ts @@ -57,7 +57,9 @@ const buildNotifications = async (appStorage: App.Storage) => { for (const walletId of walletIds) { const wallet = walletManager.getWalletById(walletId) if (!wallet) continue - const storage = buildProcessedNotificationsStorage(appStorage.join(`wallet/${walletId}/${storageKey}/`)) + + const fullStorageKey = `wallet/${walletId}/${wallet.networkManager.network}/${storageKey}/` as const + const storage = buildProcessedNotificationsStorage(appStorage.join(fullStorageKey)) const processed = await storage.getValues() const allTxIds = getTxIds(wallet)