Skip to content

Commit

Permalink
add shutdown popup warning
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul authored and TonyGiorgio committed Aug 19, 2024
1 parent 6fbd9f8 commit 8ebce65
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 2 deletions.
8 changes: 7 additions & 1 deletion e2e/encrypt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ test("test local encrypt", async ({ page }) => {
// Click the "Decrypt Wallet" button
await page.click("text=Decrypt Wallet");

// Wait for an element matching the selector to appear in DOM.
// Should have a balance up top now
await page.locator(`text=0 sats`).first().waitFor();

const shutdownPopup = page.getByText("Mutiny Wallet is Shutting Down");
if (await shutdownPopup.isVisible()) {
// Click the close button
await page.getByRole("button").nth(1).click();
}
});
6 changes: 6 additions & 0 deletions e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export async function loadHome(page: Page) {

// Should have a balance up top now
await page.locator(`text=0 sats`).first().waitFor();

const shutdownPopup = page.getByText("Mutiny Wallet is Shutting Down");
if (await shutdownPopup.isVisible()) {
// Click the close button
await page.getByRole("button").nth(1).click();
}
}

export async function visitSettings(page: Page) {
Expand Down
4 changes: 4 additions & 0 deletions public/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
"just_me": "Just Me",
"friends": "Friends",
"requests": "Requests"
},
"shutdown": {
"title": "Mutiny Wallet is Shutting Down",
"message": "We are shutting down the hosted version of Mutiny Wallet. To learn about moving your funds, or self-hosting your wallet, please visit our blog."
}
},
"profile": {
Expand Down
2 changes: 2 additions & 0 deletions src/components/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
FederationPopup,
LoadingShimmer,
NiceP,
ShutdownPopup,
SimpleDialog
} from "~/components";
import { useI18n } from "~/i18n/context";
Expand Down Expand Up @@ -428,6 +429,7 @@ export function CombinedActivity() {
<Show when={state.expiration_warning}>
<FederationPopup />
</Show>
<ShutdownPopup />
<Show when={!state.has_backed_up}>
<ButtonCard
red
Expand Down
36 changes: 36 additions & 0 deletions src/components/ShutdownPopup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { createSignal } from "solid-js";

import { ExternalLink, NiceP, SimpleDialog } from "~/components/layout";
import { useI18n } from "~/i18n/context";
import { useMegaStore } from "~/state/megaStore";

export function ShutdownPopup() {
const [state, actions, _sw] = useMegaStore();
const selfHosted =
state.settings?.selfhosted && state.settings?.selfhosted === "true";
const [showShutdownWarning, setShowShutdownWarning] = createSignal(
!selfHosted && !state.shutdown_warning_seen
);

const i18n = useI18n();

return (
<SimpleDialog
title={`${i18n.t("home.shutdown.title")}`}
open={showShutdownWarning()}
setOpen={(open: boolean) => {
if (!open) {
setShowShutdownWarning(false);
actions.clearShutdownWarning();
}
}}
>
<NiceP>{i18n.t("home.shutdown.message")}</NiceP>
<NiceP>
<ExternalLink href="https://blog.mutinywallet.com/mutiny-timeline/">
Learn more
</ExternalLink>
</NiceP>
</SimpleDialog>
);
}
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ export * from "./ImportNsecForm";
export * from "./LightningAddressShower";
export * from "./FederationInviteShower";
export * from "./FederationPopup";
export * from "./ShutdownPopup";
7 changes: 6 additions & 1 deletion src/state/megaStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export const makeMegaStoreContext = () => {
federationName: string;
}
| undefined,
expiration_warning_seen: false
expiration_warning_seen: false,
shutdown_warning_seen: false
});

const actions = {
Expand Down Expand Up @@ -638,6 +639,10 @@ export const makeMegaStoreContext = () => {
// Only show the expiration warning once per session
clearExpirationWarning() {
setState({ expiration_warning_seen: true });
},
// Only show the shutdown warning once per session
clearShutdownWarning() {
setState({ shutdown_warning_seen: true });
}
};

Expand Down

0 comments on commit 8ebce65

Please sign in to comment.