Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
refactor: use outgoingMessageSubject
Browse files Browse the repository at this point in the history
  • Loading branch information
xstelea committed Nov 1, 2023
1 parent 0ea82b7 commit 7028b54
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
29 changes: 15 additions & 14 deletions lib/connector-extension/connector-extension-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,32 +213,33 @@ export const ConnectorExtensionClient = (
removeEventListener(eventType.incomingMessage, handleIncomingMessage)
},
openPopup: () => {
window.dispatchEvent(
new CustomEvent(eventType.outgoingMessage, {
detail: { discriminator: 'openPopup' },
})
)
subjects.outgoingMessageSubject.next({
interactionId: crypto.randomUUID(),
discriminator: 'openPopup',
})
},
extensionStatus$: of(true).pipe(
tap(() => {
map(() => {
const interactionId = crypto.randomUUID()
subjects.outgoingMessageSubject.next({
interactionId: crypto.randomUUID(),
interactionId,
discriminator: 'extensionStatus',
})
return interactionId
}),
switchMap(() =>
switchMap((interactionId) =>
race(
extensionStatusEvent$,
merge(
extensionStatusEvent$,
timer(config.extensionDetectionTime).pipe(
map(
() =>
({
eventType: 'extensionStatus',
isWalletLinked: false,
isExtensionAvailable: false,
} as MessageLifeCycleExtensionStatusEvent)
(): MessageLifeCycleExtensionStatusEvent => ({
interactionId,
eventType: 'extensionStatus',
isWalletLinked: false,
isExtensionAvailable: false,
})
)
)
)
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"vite-tsconfig-paths": "^4.2.0"
},
"dependencies": {
"@radixdlt/radix-connect-schemas": "^1.0.0",
"@radixdlt/radix-connect-schemas": "^1.1.0",
"neverthrow": "^6.0.0",
"rxjs": "^7.8.1",
"tslog": "4.8.0",
Expand Down

0 comments on commit 7028b54

Please sign in to comment.