Skip to content

Commit

Permalink
Rename showNotifications
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Nov 20, 2024
1 parent aec5c96 commit f7d9756
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .changeset/poor-carrots-wink.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"@onflow/fcl": minor
---

Add `walletconnect.showNotifications` config option to disable WC notification UI
Add `walletconnect.disableNotifications` config option to disable WC notification UI
2 changes: 1 addition & 1 deletion packages/fcl-wc/src/fcl-wc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface FclWalletConnectConfig {
wcRequestHook?: any
pairingModalOverride?: any
wallets?: any[]
showNotifications?: boolean
disableNotifications?: boolean
}

const DEFAULT_RELAY_URL = "wss://relay.walletconnect.com"
Expand Down
9 changes: 5 additions & 4 deletions packages/fcl-wc/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const makeServicePlugin = (
wallets: [],
wcRequestHook: null,
pairingModalOverride: null,
showNotifications: true,
disableNotifications: false,
}
) => ({
name: SERVICE_PLUGIN_NAME,
Expand Down Expand Up @@ -62,7 +62,7 @@ const makeExec = (
abortSignal?: AbortSignal
user: any
}) => {
const {wcRequestHook, pairingModalOverride, showNotifications} = config
const {wcRequestHook, pairingModalOverride, disableNotifications: appDisabledNotifications} = config

const client = await clientPromise
invariant(!!client, "WalletConnect is not initialized")
Expand Down Expand Up @@ -118,12 +118,13 @@ const makeExec = (
openDeeplink(appLink)
}

// Show notification to the user if enabled
// Show notification to the user if not disabled by app developer or wallet
const walletDisabledNotifications =
session?.sessionProperties?.["fclWc.disableNotificationsOnMobile"] ===
"true"

const notification =
showNotifications && !walletDisabledNotifications
!appDisabledNotifications && !walletDisabledNotifications
? showWcRequestNotification({
user,
service,
Expand Down
10 changes: 5 additions & 5 deletions packages/fcl/src/utils/walletconnect/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ export function initFclWcLoader() {
config.subscribe(async (fullConfig: any) => {
const wcConfig = {
"walletconnect.projectId": fullConfig["walletconnect.projectId"],
"walletconnect.showNotifications":
fullConfig["walletconnect.showNotifications"],
"walletconnect.disableNotifications":
fullConfig["walletconnect.disableNotifications"],
"app.detail.title": fullConfig["app.detail.title"],
"app.detail.icon": fullConfig["app.detail.icon"],
"app.detail.description": fullConfig["app.detail.description"],
"app.detail.url": fullConfig["app.detail.url"],
}
const projectId: string | undefined = wcConfig["walletconnect.projectId"]
const showNotifications: boolean | undefined =
wcConfig["walletconnect.showNotifications"]
const disableNotifications: boolean | undefined =
wcConfig["walletconnect.disableNotifications"]

// Check if the plugin is already loaded by this loader, but with different configuration
// The plugin can only be loaded once
Expand Down Expand Up @@ -102,7 +102,7 @@ ${lastConfig}`
const {clientPromise: _clientPromise, FclWcServicePlugin} = fclWc.initLazy({
projectId,
metadata: getMetadata(wcConfig),
showNotifications: showNotifications,
disableNotifications: disableNotifications,
})
pluginRegistry.add([FclWcServicePlugin])
})
Expand Down

0 comments on commit f7d9756

Please sign in to comment.