Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set lsps settings via url query params #908

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions src/router.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
// @refresh reload
import { App as CapacitorApp } from "@capacitor/app";
import { Capacitor } from "@capacitor/core";
import { Route, Routes, useNavigate } from "@solidjs/router";
import { Match, onCleanup, Switch } from "solid-js";
import {
Route,
Routes,
useLocation,
useNavigate,
useSearchParams
} from "@solidjs/router";
import { Match, onCleanup, onMount, Switch } from "solid-js";

import { SetupErrorDisplay, Toaster } from "~/components";
import { SetupErrorDisplay, showToast, Toaster } from "~/components";
import { setSettings } from "~/logic/mutinyWalletSetup";
import {
Activity,
Feedback,
Expand Down Expand Up @@ -37,6 +44,7 @@
} from "~/routes/settings";

import { useMegaStore } from "./state/megaStore";
import { eify } from "./utils";

function GlobalListeners() {
// listeners for native navigation handling
Expand Down Expand Up @@ -83,6 +91,33 @@

export function Router() {
const [state, _] = useMegaStore();
const location = useLocation();
const [searchParams, setSearchParams] = useSearchParams();
const navigate = useNavigate();

Check warning on line 96 in src/router.tsx

View workflow job for this annotation

GitHub Actions / code_quality

'setSearchParams' is assigned a value but never used. Allowed unused elements of array destructuring patterns must match /^_/u

if (searchParams.lsps) {
const values = {
lsp: "",
lsps_connection_string: searchParams.lsps,
lsps_token: searchParams.token
};
onMount(async () => {
try {
await state.mutiny_wallet?.change_lsp(
values.lsp ? values.lsp : undefined,
values.lsps_connection_string
? values.lsps_connection_string
: undefined,
values.lsps_token ? values.lsps_token : undefined
);
await setSettings(values);
navigate(location.pathname, { replace: true });
} catch (e) {
console.error("Error changing lsp:", e);
showToast(eify(e));
}
});
}

return (
<Switch>
Expand Down
Loading