Skip to content

Commit

Permalink
Add fclWc.disableUNotifications session property
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Nov 16, 2024
1 parent 0d78d75 commit 9d330ca
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/fcl-wc/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {showNotification} from "./ui/notifications"
import type {FclWalletConnectConfig} from "./fcl-wc"
import mobileIcon from "./ui/assets/mobile.png"
import {CurrentUser, Service} from "@onflow/typedefs"
import { SessionTypes } from "@walletconnect/types"

type WalletConnectModalType = import("@walletconnect/modal").WalletConnectModal

Expand Down Expand Up @@ -66,7 +67,7 @@ const makeExec = (
const client = await clientPromise
invariant(!!client, "WalletConnect is not initialized")

let session: any, pairing: any
let session: SessionTypes.Struct | null = null, pairing: any
const method = service.endpoint
const appLink = validateAppLink(service)
const pairings = client.pairing.getAll({active: true})
Expand All @@ -81,7 +82,7 @@ const makeExec = (
}

if (session == null) {
session = await new Promise((resolve, reject) => {
session = await new Promise<SessionTypes.Struct>((resolve, reject) => {
function onClose() {
reject(`Declined: Externally Halted`)
}
Expand Down Expand Up @@ -117,7 +118,8 @@ const makeExec = (
}

// Show notification to the user if enabled
const notification = showNotifications
const walletDisabledNotifications = session?.sessionProperties?.["fclWc.disableUiNotifications"] === "true"
const notification = showNotifications && !walletDisabledNotifications
? showWcRequestNotification({
user,
service,
Expand Down Expand Up @@ -170,7 +172,7 @@ function connectWc(
wcRequestHook: any
pairingModalOverride: any
abortSignal?: AbortSignal
}) => {
}): Promise<SessionTypes.Struct> => {
const projectId = client.opts?.projectId
invariant(
!!projectId,
Expand Down Expand Up @@ -230,7 +232,7 @@ function connectWc(

const session = await Promise.race([
approval(),
new Promise((_, reject) => {
new Promise<never>((_, reject) => {
if (abortSignal?.aborted) {
reject(new Error("Session request aborted"))
}
Expand Down

0 comments on commit 9d330ca

Please sign in to comment.