Skip to content

Commit

Permalink
fix: wagmi not showing loading indicator on email reconnection (#2682)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir authored Aug 9, 2024
1 parent fc8a93b commit d49161a
Show file tree
Hide file tree
Showing 4 changed files with 13,864 additions and 10,377 deletions.
5 changes: 5 additions & 0 deletions apps/laboratory/tests/email.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ emailTest('it should switch network and sign', async () => {
await validator.expectAcceptedSign()
})

emailTest.only('it should show loading on page refresh', async () => {
await page.page.reload()
await validator.expectConnectButtonLoading()
})

emailTest('it should disconnect correctly', async () => {
await page.openAccount()
await page.openProfileView()
Expand Down
5 changes: 5 additions & 0 deletions apps/laboratory/tests/shared/validators/ModalValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,9 @@ export class ModalValidator {
const networkOptions = this.page.getByTestId(`w3m-network-switch-${name}`)
await expect(networkOptions).toBeDisabled()
}

async expectConnectButtonLoading() {
const connectButton = this.page.getByTestId('connect-button')
await expect(connectButton).toContainText('Connecting...')
}
}
15 changes: 12 additions & 3 deletions packages/wagmi/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,18 @@ export class Web3Modal extends Web3ModalScaffold {
isDisconnected,
chainId,
connector,
addresses
addresses,
status
}: Partial<
Pick<
GetAccountReturnType,
'address' | 'isConnected' | 'isDisconnected' | 'chainId' | 'connector' | 'addresses'
| 'address'
| 'isConnected'
| 'isDisconnected'
| 'chainId'
| 'connector'
| 'addresses'
| 'status'
>
>) {
const caipAddress: CaipAddress = `${ConstantsUtil.EIP155}:${chainId}:${address}`
Expand All @@ -463,7 +470,9 @@ export class Web3Modal extends Web3ModalScaffold {
return
}

if (isConnected && address && chainId) {
const connected = isConnected && status === 'connected'

if (connected && address && chainId) {
this.resetAccount()
this.syncNetwork(address, chainId, isConnected)
this.setIsConnected(isConnected)
Expand Down
Loading

0 comments on commit d49161a

Please sign in to comment.