Skip to content

Commit

Permalink
fix: avoid crash when changing tab in send asset popup
Browse files Browse the repository at this point in the history
  • Loading branch information
VmMad committed Sep 25, 2023
1 parent ded59fa commit 2bbc642
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions packages/shared/components/inputs/NftInput.svelte
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<script lang="ts">
import { Modal, SelectorInput, IOption, NftImageOrIconBox, NftSize } from 'shared/components'
import { ownedNfts } from '@core/nfts'
import { INft, ownedNfts } from '@core/nfts'
import { getNftByIdFromAllAccountNfts } from '@core/nfts'
import { selectedAccountIndex } from '@core/account'
import { localize } from '@core/i18n'
import { time } from '@core/app'
export let nftId: string = ''
export let error: string = ''
export let readonly: boolean = null
export let readonly: boolean | null = null
let inputElement: HTMLInputElement = undefined
let selectedNftById: INft | undefined
let modal: Modal = undefined
let selected: IOption = nftId
? { key: getNftByIdFromAllAccountNfts($selectedAccountIndex, nftId).name, value: nftId }
: {}
let inputElement: HTMLInputElement | undefined = undefined
let selected: IOption = selectedNftById ? { key: selectedNftById.name, value: selectedNftById.id } : {}
const nftOptions: IOption[] = $ownedNfts
.filter((nft) => nft.isSpendable && (!nft.timelockTime || nft.timelockTime < $time.getTime()))
.map((_nft) => ({ key: _nft.name, value: _nft.id }))
$: selectedNftById = getNftByIdFromAllAccountNfts($selectedAccountIndex, nftId)
$: nftId = selected?.value
export async function validate(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { allAccountNfts } from '../stores'
import { INft } from '../interfaces'
import { get } from 'svelte/store'

export function getNftByIdFromAllAccountNfts(accountIndex: number, nftId: string): INft {
export function getNftByIdFromAllAccountNfts(accountIndex: number, nftId: string): INft | undefined {
return get(allAccountNfts)[accountIndex]?.find((_nft) => _nft.id === nftId)
}

0 comments on commit 2bbc642

Please sign in to comment.