From 9f6efc331299eae63cc70868214077a4a1d08ace Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Tue, 3 Sep 2024 12:39:32 -0500 Subject: [PATCH] hide voltage option for new wallets remove voltage lsp option if not using voltage --- src/routes/settings/Servers.tsx | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/routes/settings/Servers.tsx b/src/routes/settings/Servers.tsx index 75b3d4d9..ff079b76 100644 --- a/src/routes/settings/Servers.tsx +++ b/src/routes/settings/Servers.tsx @@ -113,11 +113,36 @@ function SettingsStringsEditor(props: { } ]; - const LSP_OPTIONS = + const LSP_OPTIONS_WITH_VOLTAGE = props.initialSettings.network === "signet" ? SIGNET_LSP_OPTIONS : MAINNET_LSP_OPTIONS; + // If the user already has a non-voltage LSP, remove Voltage from the list + function filterOutVoltage(lspOptions: { value: string; label: string }[]) { + if ( + props.initialSettings.network === "signet" && + props.initialSettings.lsp && + props.initialSettings.lsp !== "https://signet-lsp.mutinywallet.com" + ) { + return lspOptions.filter( + (option) => + option.value !== "https://signet-lsp.mutinywallet.com" + ); + } + + if ( + props.initialSettings.lsp && + props.initialSettings.lsp !== "https://lsp.voltageapi.com" + ) { + return lspOptions.filter( + (option) => option.value !== "https://lsp.voltageapi.com" + ); + } + } + + const LSP_OPTIONS = filterOutVoltage(LSP_OPTIONS_WITH_VOLTAGE); + return (