Skip to content

Commit 9a76487

Browse files
committed
Store check modules in app state, so can be reset
1 parent a908718 commit 9a76487

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

src/stores.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
WalletStateSliceStore,
1010
StateSyncer,
1111
BalanceStore,
12-
CancelablePromise
12+
CancelablePromise,
13+
WalletCheckModule
1314
} from './interfaces'
1415

1516
export const app: WritableStore = writable({
@@ -24,7 +25,8 @@ export const app: WritableStore = writable({
2425
walletCheckInProgress: false,
2526
walletCheckCompleted: false,
2627
accountSelectInProgress: false,
27-
autoSelectWallet: ''
28+
autoSelectWallet: '',
29+
checkModules: []
2830
})
2931

3032
export const balanceSyncStatus: {
@@ -144,12 +146,17 @@ export function resetWalletState(options?: {
144146
return currentInterface
145147
})
146148

147-
app.update(store => ({
148-
...store,
149-
walletSelectInProgress: false,
150-
walletSelectCompleted: false,
151-
autoSelect: false
152-
}))
149+
app.update(store => {
150+
Array.isArray(store.checkModules) &&
151+
store.checkModules.forEach((m: WalletCheckModule) => m.reset && m.reset())
152+
153+
return {
154+
...store,
155+
walletSelectInProgress: false,
156+
walletSelectCompleted: false,
157+
autoSelect: false
158+
}
159+
})
153160
}
154161

155162
function createWalletInterfaceStore(

src/views/Onboard.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
} from '../interfaces'
1212
1313
export let walletSelectModule: WalletSelectModule
14-
export let walletCheckModules: WalletCheckModule
1514
export let walletSelect: WalletSelectFunction
1615
</script>
1716

@@ -41,7 +40,7 @@
4140
{/if}
4241

4342
{#if $app.walletCheckInProgress}
44-
<WalletCheck modules={walletCheckModules} {walletSelect} />
43+
<WalletCheck {walletSelect} />
4544
{/if}
4645

4746
{#if $app.accountSelectInProgress}

src/views/WalletCheck.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
UserState
2929
} from '../interfaces'
3030
31-
export let modules: WalletCheckModule[] | Promise<WalletCheckModule[]> = []
3231
export let walletSelect: WalletSelectFunction
3332
3433
const blocknative = getBlocknative()
@@ -57,9 +56,12 @@
5756
async function renderModule() {
5857
checkingModule = true
5958
59+
let modules = get(app).checkModules
60+
6061
if (isPromise(modules)) {
6162
modules = await modules
6263
modules.forEach(validateWalletCheckModule)
64+
app.update(store => ({ ...store, checkModules: modules }))
6365
}
6466
6567
const currentWallet = get(wallet).name

0 commit comments

Comments
 (0)