mirror of
https://github.com/joinmarket-webui/jam.git
synced 2026-08-19 13:18:30 +02:00
fix: do not re-apply initial row selection
This commit is contained in:
parent
0b17392c97
commit
d67152b373
3 changed files with 12 additions and 26 deletions
|
|
@ -39,6 +39,7 @@ import type { WalletFileName } from '@/lib/utils'
|
|||
import { useDeveloperMode } from '@/store/jamSettingsStore'
|
||||
import { jmSessionStore } from '@/store/jmSessionStore'
|
||||
import { jmTxStore, type JmTxInfo } from '@/store/jmTxStore'
|
||||
import type { JarIndex } from '@/types/global'
|
||||
import { Button } from '../ui/button'
|
||||
import { Card, CardContent } from '../ui/card'
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '../ui/dialog'
|
||||
|
|
@ -81,6 +82,7 @@ export const SendPage = ({ walletFileName }: SendPageProps) => {
|
|||
const [paymentSuccessfulInfoAlert, setPaymentSuccessfulInfoAlert] = useState<SimpleAlert>()
|
||||
const [minimumCollaborators, setMinimumCollaborators] = useState<number>()
|
||||
const [collaborativeFlowError, setCollaborativeFlowError] = useState<string>()
|
||||
const [sourceJarIndex, setSourceJarIndex] = useState<JarIndex>()
|
||||
// TODO: "Lifecycle" or state management should be handled outside of this component
|
||||
const collaborativeLifecycleRef = useRef({
|
||||
awaitingCompletion: false,
|
||||
|
|
@ -108,17 +110,16 @@ export const SendPage = ({ walletFileName }: SendPageProps) => {
|
|||
refetchWalletInfoRef.current = refetchWalletInfo
|
||||
}, [refetchWalletInfo])
|
||||
|
||||
const utxoSelectionDialog = useUtxoSelectionDialog({
|
||||
walletFileName,
|
||||
jars,
|
||||
addressSummary,
|
||||
})
|
||||
|
||||
const sourceJar = useMemo(() => {
|
||||
const sourceJarIndex = sendFromValuesAwaitingConfirmation?.source?.fromJar
|
||||
if (sourceJarIndex === undefined) return
|
||||
return jars.find((it) => it.jarIndex === sourceJarIndex)
|
||||
}, [jars, sendFromValuesAwaitingConfirmation])
|
||||
}, [jars, sourceJarIndex])
|
||||
|
||||
const utxoSelectionDialog = useUtxoSelectionDialog({
|
||||
walletFileName,
|
||||
sourceJar,
|
||||
addressSummary,
|
||||
})
|
||||
|
||||
const availableUtxosForPayment = useMemo(() => {
|
||||
return (sourceJar?.utxos || []).filter((utxo) => !utxo.frozen).toSorted((a, b) => a.confirmations - b.confirmations)
|
||||
|
|
@ -594,7 +595,7 @@ export const SendPage = ({ walletFileName }: SendPageProps) => {
|
|||
waitForUtxosToBeSpent.length > 0
|
||||
}
|
||||
debug={isDeveloperMode}
|
||||
onSourceJarChange={utxoSelectionDialog.setSourceJarIndex}
|
||||
onSourceJarChange={setSourceJarIndex}
|
||||
sourceJarLabelButton={
|
||||
<Button
|
||||
type="button"
|
||||
|
|
|
|||
|
|
@ -331,12 +331,6 @@ export const JarUtxosTable = ({
|
|||
})
|
||||
}, [table, pinnedEntries])
|
||||
|
||||
useEffect(() => {
|
||||
if (!initialRowSelection) return
|
||||
setRowSelection(initialRowSelection)
|
||||
onRowSelectionChange?.(initialRowSelection)
|
||||
}, [initialRowSelection, onRowSelectionChange])
|
||||
|
||||
useEffect(() => {
|
||||
if (isShowAll) {
|
||||
table.setPageSize(tableEntries.length || 1)
|
||||
|
|
|
|||
|
|
@ -11,17 +11,16 @@ import type { Utxo } from '@/hooks/useQueryUtxos'
|
|||
import * as fb from '@/lib/fidelityBondUtils'
|
||||
import { utxoTags } from '@/lib/tags'
|
||||
import type { WalletFileName } from '@/lib/utils'
|
||||
import type { JarIndex } from '@/types/global'
|
||||
|
||||
const SEND_AUTO_SELECTION_TOAST_ID = 'send.utxo.selection_changed_automatically'
|
||||
|
||||
interface UseUtxoSelectionDialogProps {
|
||||
walletFileName: WalletFileName
|
||||
jars: Jar[]
|
||||
sourceJar?: Jar
|
||||
addressSummary: AddressSummary
|
||||
}
|
||||
|
||||
export const useUtxoSelectionDialog = ({ walletFileName, jars, addressSummary }: UseUtxoSelectionDialogProps) => {
|
||||
export const useUtxoSelectionDialog = ({ walletFileName, sourceJar, addressSummary }: UseUtxoSelectionDialogProps) => {
|
||||
const { t } = useTranslation()
|
||||
const client = useApiClient()
|
||||
|
||||
|
|
@ -29,12 +28,6 @@ export const useUtxoSelectionDialog = ({ walletFileName, jars, addressSummary }:
|
|||
const [open, setOpen] = useState(false)
|
||||
const [filter, setFilter] = useState('')
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
|
||||
const [sourceJarIndex, setSourceJarIndex] = useState<JarIndex>()
|
||||
|
||||
const sourceJar = useMemo(() => {
|
||||
if (sourceJarIndex === undefined) return
|
||||
return jars.find((it) => it.jarIndex === sourceJarIndex)
|
||||
}, [jars, sourceJarIndex])
|
||||
|
||||
const tableEntries = useMemo(() => {
|
||||
return (sourceJar?.utxos || []).map((utxo) => ({
|
||||
|
|
@ -192,8 +185,6 @@ export const useUtxoSelectionDialog = ({ walletFileName, jars, addressSummary }:
|
|||
|
||||
return {
|
||||
isApplying,
|
||||
sourceJarIndex,
|
||||
setSourceJarIndex,
|
||||
onOpenUtxoSelector,
|
||||
utxoSelectorDisabled: isApplying || sourceJar === undefined || sourceJar.utxos.length === 0,
|
||||
dialogProps,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue