Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/common/src/store/account/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,16 @@ function* fetchLocalAccountAsync() {
users: [cachedAccountUser],
queryClient
})
// Set walletAddresses so useCurrentAccount/useWalletAddresses work correctly.
// Without this, components that depend on currentUserWallet stay disabled.
const web3WalletAddress = wallet
yield* put(
setWalletAddresses({ currentUser: wallet, web3User: web3WalletAddress })
)
queryClient.setQueryData(getWalletAddressesQueryKey(), {
currentUser: wallet,
web3User: web3WalletAddress
})
queryClient.setQueryData(getAccountStatusQueryKey(), Status.SUCCESS)
yield* put(fetchAccountSucceeded(cachedAccount))
}
Expand Down
24 changes: 24 additions & 0 deletions packages/web/src/common/store/pages/signon/sagas.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {
getAccountStatusQueryKey,
getCurrentAccountQueryKey,
getWalletAccountSaga,
getUserQueryKey,
primeUserData,
queryAccountUser,
queryHasAccount,
queryIsAccountComplete,
Expand Down Expand Up @@ -523,6 +526,27 @@ function* signUp() {
})
)

// Optimistically update localStorage so getLocalAccount returns
// complete user data before discovery provider has indexed.
const updatedUser = {
...account.user,
handle,
handle_lc: handle.toLowerCase(),
name,
location: location ?? null
}
yield* call(
[localStorage, localStorage.setAudiusAccountUser],
updatedUser
)
primeUserData({ users: [updatedUser], queryClient })
queryClient.invalidateQueries({
queryKey: getUserQueryKey(userId)
})
queryClient.invalidateQueries({
queryKey: getCurrentAccountQueryKey()
})

return userId
} else {
const authService = yield* getContext('authService')
Expand Down
13 changes: 9 additions & 4 deletions packages/web/src/hooks/useRequiresAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
updateRouteOnExit
} from 'common/store/pages/signon/actions'

let hasShownRequiresAccountToastThisSession = false

export type RestrictionType = 'none' | 'guest' | 'account'

const canAccess = (
Expand Down Expand Up @@ -72,11 +74,14 @@ export const useRequiresAccountCallback = <T extends (...args: any) => any>(
dispatch(updateRouteOnExit(returnRoute))
dispatch(updateRouteOnCompletion(returnRoute))
dispatch(openSignOn(/** signIn */ false))
dispatch(
showRequiresAccountToast(
accountStatus === Status.SUCCESS && !isAccountComplete
if (!hasShownRequiresAccountToastThisSession) {
hasShownRequiresAccountToastThisSession = true
dispatch(
showRequiresAccountToast(
accountStatus === Status.SUCCESS && !isAccountComplete
)
)
)
}
onOpenAuthModal?.()
return
}
Expand Down