Skip to content

Commit 117e306

Browse files
committed
add additional tester
1 parent 379c56f commit 117e306

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/components/ConnectButton.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ onMounted(async () => {
7272
const [{ connection }] = await Promise.all([
7373
import('@devprotocol/clubs-core/connection'),
7474
load('//cdn.jsdelivr.net/npm/buffer@6'),
75-
load('//cdn.jsdelivr.net/npm/@web3auth/modal'),
75+
load('//cdn.jsdelivr.net/npm/@web3auth/modal', () =>
76+
Boolean(window.Modal?.Web3Auth),
77+
),
7678
])
7779
web3auth = new window.Modal.Web3Auth({
7880
clientId: props.web3authClientId,

src/utils/load.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
/* eslint-disable functional/immutable-data */
33
/* eslint-disable functional/no-expression-statements */
44

5-
export const load = async (src: string): Promise<true> => {
5+
export const load = async <T extends boolean = boolean>(
6+
src: string,
7+
test?: () => Promise<T> | T,
8+
): Promise<true> => {
69
const id = `__load_${window.btoa(src)}__`
710

811
const exists = Boolean(document.getElementById(id))
12+
const testResult = test ? await test() : true
913

10-
console.log({ id, exists })
14+
console.log({ id, exists, testResult })
1115

12-
return exists
16+
return exists || testResult
1317
? true
1418
: new Promise((resolve) => {
1519
const script = document.createElement('script')

0 commit comments

Comments
 (0)