add safe mode view

This commit is contained in:
Paul Miller
2023-08-16 15:23:31 -05:00
parent 2d5f96788f
commit 754b8ab7c2
6 changed files with 67 additions and 23 deletions

View File

@@ -69,7 +69,7 @@ export default function App() {
</Show>
<BalanceBox loading={state.wallet_loading} />
<Suspense>
<Show when={!state.wallet_loading}>
<Show when={!state.wallet_loading && !state.safe_mode}>
<PendingNwc />
</Show>
</Suspense>

View File

@@ -1,10 +1,11 @@
import { Show } from "solid-js";
import { Match, Show, Switch } from "solid-js";
import { Button, FancyCard, Indicator } from "~/components/layout";
import { useMegaStore } from "~/state/megaStore";
import { AmountSats, AmountFiat } from "./Amount";
import { A, useNavigate } from "solid-start";
import shuffle from "~/assets/icons/shuffle.svg";
import { useI18n } from "~/i18n/context";
import { InfoBox } from "./InfoBox";
export function LoadingShimmer() {
return (
@@ -43,22 +44,38 @@ export default function BalanceBox(props: { loading?: boolean }) {
<>
<FancyCard>
<Show when={!props.loading} fallback={<LoadingShimmer />}>
<Switch>
<Match when={state.safe_mode}>
<div class="flex flex-col gap-1">
<InfoBox accent="red">
{i18n.t("common.error_safe_mode")}
</InfoBox>
</div>
</Match>
<Match when={true}>
<div class="flex flex-col gap-1">
<div class="text-2xl">
<AmountSats
amountSats={state.balance?.lightning || 0}
amountSats={
state.balance?.lightning || 0
}
icon="lightning"
denominationSize="lg"
/>
</div>
<div class="text-lg text-white/70">
<AmountFiat
amountSats={state.balance?.lightning || 0}
amountSats={
state.balance?.lightning || 0
}
denominationSize="sm"
/>
</div>
</div>
</Match>
</Switch>
</Show>
<hr class="my-2 border-m-grey-750" />
<Show when={!props.loading} fallback={<LoadingShimmer />}>
<div class="flex justify-between">

View File

@@ -60,6 +60,18 @@ export default function SetupErrorDisplay(props: { initialError: Error }) {
</ExternalLink>{" "}
for updates.
</NiceP>
<NiceP>
{i18n.t(
"error.on_boot.loading_failed.in_the_meantime"
)}{" "}
<a href="/?safe_mode=true">
{" "}
{i18n.t(
"error.on_boot.loading_failed.safe_mode"
)}
</a>
.
</NiceP>
<ErrorFooter />
</DefaultMain>

View File

@@ -19,7 +19,9 @@ export default {
why: "Why?",
private_tags: "Private tags",
view_transaction: "View Transaction",
pending: "Pending"
pending: "Pending",
error_safe_mode:
"Mutiny is running in safe mode. Lightning is disabled."
},
contacts: {
new: "new",
@@ -479,7 +481,10 @@ export default {
"If you have any questions on what these buttons do, please",
support_link: "reach out to us for support.",
services_down:
"It looks like one of Mutiny's services is down. Please try again later."
"It looks like one of Mutiny's services is down. Please try again later.",
in_the_meantime:
"In the meantime if you want to access your on-chain funds you can load Mutiny in",
safe_mode: "Safe Mode"
}
}
},

View File

@@ -163,7 +163,8 @@ export async function initializeWasm() {
export async function setupMutinyWallet(
settings: MutinyWalletSettingStrings,
password?: string
password?: string,
safeMode?: boolean
): Promise<MutinyWallet> {
console.log("Starting setup...");
@@ -189,6 +190,7 @@ export async function setupMutinyWallet(
console.log("Using subscriptions address", subscriptions);
console.log("Using storage address", storage);
console.log("Using scorer address", scorer);
console.log(safeMode ? "Safe mode enabled" : "Safe mode disabled");
const mutinyWallet = await new MutinyWallet(
// Password
@@ -207,7 +209,9 @@ export async function setupMutinyWallet(
// Do not connect peers
undefined,
// Do not skip device lock
undefined
undefined,
// Safe mode
safeMode || undefined
);
sessionStorage.setItem("MUTINY_WALLET_INITIALIZED", Date.now().toString());

View File

@@ -24,6 +24,7 @@ import eify from "~/utils/eify";
import { timeout } from "~/utils/timeout";
import { ParsedParams } from "~/logic/waila";
import { subscriptionValid } from "~/utils/subscriptions";
import { useSearchParams } from "solid-start";
const MegaStoreContext = createContext<MegaStore>();
@@ -53,6 +54,7 @@ export type MegaStore = [
needs_password: boolean;
load_stage: LoadStage;
settings?: MutinyWalletSettingStrings;
safe_mode?: boolean;
},
{
setup(password?: string): Promise<void>;
@@ -67,6 +69,8 @@ export type MegaStore = [
];
export const Provider: ParentComponent = (props) => {
const [searchParams] = useSearchParams();
const [state, setState] = createStore({
mutiny_wallet: undefined as MutinyWallet | undefined,
deleting: false,
@@ -87,7 +91,8 @@ export const Provider: ParentComponent = (props) => {
},
needs_password: false,
load_stage: "fresh" as LoadStage,
settings: undefined as MutinyWalletSettingStrings | undefined
settings: undefined as MutinyWalletSettingStrings | undefined,
safe_mode: searchParams.safe_mode === "true"
});
const actions = {
@@ -132,7 +137,8 @@ export const Provider: ParentComponent = (props) => {
const mutinyWallet = await setupMutinyWallet(
settings,
password
password,
state.safe_mode
);
// Give other components access to settings via the store