mirror of
https://github.com/joinmarket-webui/jam.git
synced 2026-08-13 12:33:26 +02:00
fix(login): wallet preselection (#1296)
This commit is contained in:
parent
3fc3ff3d58
commit
d9bf64fb02
3 changed files with 10 additions and 8 deletions
|
|
@ -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),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue