fix(login): wallet preselection (#1296)
Some checks failed
Build / build (v26.3.0) (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Deploy Storybook / deploy (push) Has been cancelled

This commit is contained in:
Thebora Kompanioni 2026-06-24 15:42:48 +02:00 committed by GitHub
parent 3fc3ff3d58
commit d9bf64fb02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 8 deletions

View file

@ -61,7 +61,7 @@ export const LoginFormComponent = ({
className,
wallets,
activeWallet,
preselectedWallet = activeWallet,
preselectedWallet = activeWallet ?? (wallets.length === 1 ? wallets[0] : undefined),
makerRunning,
coinjoinInProgress,
onSubmit,
@ -85,7 +85,7 @@ export const LoginFormComponent = ({
mode: 'onSubmit',
reValidateMode: 'onSubmit',
defaultValues: {
walletFileName: preselectedWallet ?? (wallets.length === 1 ? wallets[0] : undefined),
walletFileName: preselectedWallet,
},
resolver: yupResolver(schema),
})

View file

@ -9,7 +9,7 @@ import { useApiClient } from '@/hooks/useApiClient'
import { getErrorReason } from '@/lib/errorReason'
import { hashPassword } from '@/lib/hash'
import { withQueryDelay } from '@/lib/queryClient'
import { sortWallets } from '@/lib/utils'
import { isWalletFileName, sortWallets } from '@/lib/utils'
import type { WalletFileName } from '@/lib/utils'
import { authStore, type AuthState } from '@/store/authStore'
import { jmSessionStore } from '@/store/jmSessionStore'
@ -46,10 +46,8 @@ const LoginPage = () => {
}),
})
const activeWalletOrNull =
jmSession?.wallet_name !== undefined && jmSession.wallet_name !== 'None'
? (jmSession?.wallet_name as WalletFileName)
: null
const activeWalletOrNull: WalletFileName | null =
jmSession?.session === true && isWalletFileName(jmSession.wallet_name) ? jmSession.wallet_name : null
const wallets = sortWallets((listWalletsData?.wallets || []) as WalletFileName[], activeWalletOrNull)
const unlockWallet = useMutation({

View file

@ -22,7 +22,11 @@ export const isRelativeOffer = (offertype: OfferType) => offertype.includes('rel
// can be any of ['sw0absoffer', 'swabsoffer', 'absoffer']
export const isAbsoluteOffer = (offertype: OfferType) => offertype.includes('absoffer')
export type WalletFileName = `${string}.jmdat`
export type WalletFileName = `${string}${typeof JM_WALLET_FILE_EXTENSION}`
export function isWalletFileName(val: unknown): val is WalletFileName {
return typeof val === 'string' && val.endsWith(JM_WALLET_FILE_EXTENSION)
}
/**
* Formats a wallet name by removing the .jmdat extension