diff --git a/frontend/src/pages/LndState/LndState.tsx b/frontend/src/pages/LndState/LndState.tsx index c5fabe4..217f635 100644 --- a/frontend/src/pages/LndState/LndState.tsx +++ b/frontend/src/pages/LndState/LndState.tsx @@ -8,8 +8,7 @@ import { GetLndRest, GetLndAdminMacaroonPath, GetLndChainInfo, - InitWallet, - GetDefaultLndDir, OpenFileSelector + OpenFileSelector } from '../../../wailsjs/go/main/App'; import { Input } from "@/components/ui/input" import { Button } from '@/components/ui/button'; @@ -165,7 +164,7 @@ function LndState() { progressRef.current = null } } - }, [isWalletRpcReady]) + }, [isWalletRpcReady]) useEffect(() => { if (!initState.current) { @@ -189,23 +188,26 @@ function LndState() { }, []) async function ChooseLndDir() { - try { - const chooseedLndDir = await OpenFileSelector(frontend.OpenDialogOptions.createFrom({ - 'DefaultDirectory': LndInfo.path, - 'DefaultFilename': 'admin', - 'Title': 'Select Lnd Data Directory', - 'ShowHiddenFiles': true, - 'CanCreateDirectories': true, - 'ResolvesAliases': true, - 'TreatPackagesAsDirectories': false, - })) - } catch (error) { - toast({ - variant: "destructive", - title: "Lnd Data File Error", - description: String(error), - }) - } + const lastSlashIndex = LndInfo.admMacaroon.lastIndexOf('/'); + const folderPath = LndInfo.admMacaroon.substring(0, lastSlashIndex); + const fileName = LndInfo.admMacaroon.substring(lastSlashIndex + 1); + await OpenFileSelector(frontend.OpenDialogOptions.createFrom({ + 'DefaultDirectory': folderPath, + 'DefaultFilename': fileName, + 'Title': 'Select Lnd Data Directory', + 'ShowHiddenFiles': true, + 'CanCreateDirectories': false, + 'ResolvesAliases': true, + 'TreatPackagesAsDirectories': false, + 'Filters': [ + frontend.FileFilter.createFrom( + { + 'DisplayName': fileName, + 'Pattern': '*.macaroon' + } + ) + ] + })) } return ( @@ -264,7 +266,7 @@ function LndState() {
- +