-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8904d1
commit 8d2cbb4
Showing
19 changed files
with
446 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
apps/wallet-mobile/src/features/Notifications/useCases/common/mocks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {Notifications as NotificationTypes} from '@yoroi/types' | ||
import * as React from 'react' | ||
import {Subject} from 'rxjs' | ||
|
||
import {useNotificationsManager} from './hooks' | ||
import {displayNotificationEvent} from './notifications' | ||
import {createTransactionReceivedNotification} from './transaction-received-notification' | ||
|
||
export const useMockedNotifications = () => { | ||
const [transactionReceivedSubject] = React.useState(new Subject<NotificationTypes.TransactionReceivedEvent>()) | ||
const manager = useNotificationsManager({ | ||
subscriptions: { | ||
[NotificationTypes.Trigger.TransactionReceived]: transactionReceivedSubject, | ||
}, | ||
}) | ||
React.useEffect(() => { | ||
const subscription = manager.notification$.subscribe(displayNotificationEvent) | ||
return () => { | ||
subscription.unsubscribe() | ||
} | ||
}, [manager]) | ||
|
||
const triggerTransactionReceived = (metadata: NotificationTypes.TransactionReceivedEvent['metadata']) => { | ||
transactionReceivedSubject.next(createTransactionReceivedNotification(metadata)) | ||
} | ||
|
||
return {triggerTransactionReceived, manager} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.