mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-18 14:54:26 +01:00
Testing full clearing of node manager
This commit is contained in:
committed by
Paul Miller
parent
09e595dcf8
commit
ee6f532ba8
@@ -22,29 +22,7 @@ export function deleteDb(name: string) {
|
||||
}
|
||||
|
||||
export function DeleteEverything() {
|
||||
const [_store, actions] = useMegaStore();
|
||||
|
||||
async function resetNode() {
|
||||
try {
|
||||
setConfirmLoading(true);
|
||||
deleteDb("gossip")
|
||||
deleteDb("wallet")
|
||||
localStorage.clear();
|
||||
|
||||
showToast({ title: "Deleted", description: `Deleted all data` })
|
||||
|
||||
setTimeout(() => {
|
||||
window.location.href = "/";
|
||||
}, 3000);
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
showToast(eify(e))
|
||||
} finally {
|
||||
setConfirmOpen(false);
|
||||
setConfirmLoading(false);
|
||||
}
|
||||
|
||||
}
|
||||
const [_state, actions] = useMegaStore();
|
||||
|
||||
async function confirmReset() {
|
||||
setConfirmOpen(true);
|
||||
@@ -53,6 +31,25 @@ export function DeleteEverything() {
|
||||
const [confirmOpen, setConfirmOpen] = createSignal(false);
|
||||
const [confirmLoading, setConfirmLoading] = createSignal(false);
|
||||
|
||||
|
||||
async function resetNode() {
|
||||
try {
|
||||
setConfirmLoading(true);
|
||||
await actions.deleteMutinyWallet();
|
||||
showToast({ title: "Deleted", description: `Deleted all data` })
|
||||
|
||||
setTimeout(() => {
|
||||
window.location.href = "/";
|
||||
}, 1000);
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
showToast(eify(e))
|
||||
} finally {
|
||||
setConfirmOpen(false);
|
||||
setConfirmLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button onClick={confirmReset}>Delete Everything</Button>
|
||||
@@ -61,4 +58,4 @@ export function DeleteEverything() {
|
||||
</ConfirmDialog>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ type UserStatus = undefined | "new_here" | "waitlisted" | "approved" | "paid"
|
||||
export type MegaStore = [{
|
||||
waitlist_id?: string;
|
||||
mutiny_wallet?: MutinyWallet;
|
||||
deleting: boolean;
|
||||
user_status: UserStatus;
|
||||
scan_result?: ParsedParams;
|
||||
balance?: MutinyBalance;
|
||||
@@ -25,6 +26,7 @@ export type MegaStore = [{
|
||||
}, {
|
||||
fetchUserStatus(): Promise<UserStatus>;
|
||||
setupMutinyWallet(settings?: MutinyWalletSettingStrings): Promise<void>;
|
||||
deleteMutinyWallet(): Promise<void>;
|
||||
setWaitlistId(waitlist_id: string): void;
|
||||
setScanResult(scan_result: ParsedParams | undefined): void;
|
||||
sync(): Promise<void>;
|
||||
@@ -36,6 +38,7 @@ export const Provider: ParentComponent = (props) => {
|
||||
const [state, setState] = createStore({
|
||||
waitlist_id: localStorage.getItem("waitlist_id"),
|
||||
mutiny_wallet: undefined as MutinyWallet | undefined,
|
||||
deleting: false,
|
||||
user_status: undefined as UserStatus,
|
||||
scan_result: undefined as ParsedParams | undefined,
|
||||
// TODO: wire this up to real price once we have caching
|
||||
@@ -74,6 +77,16 @@ export const Provider: ParentComponent = (props) => {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
async deleteMutinyWallet(): Promise<void> {
|
||||
await state.mutiny_wallet?.stop();
|
||||
setState((prevState) => ({
|
||||
...prevState,
|
||||
mutiny_wallet: undefined,
|
||||
deleting: true,
|
||||
}));
|
||||
MutinyWallet.import_json("{}");
|
||||
localStorage.clear();
|
||||
},
|
||||
setWaitlistId(waitlist_id: string) {
|
||||
setState({ waitlist_id })
|
||||
},
|
||||
@@ -115,7 +128,7 @@ export const Provider: ParentComponent = (props) => {
|
||||
|
||||
// Only load node manager when status is approved
|
||||
createEffect(() => {
|
||||
if (state.user_status === "approved" && !state.mutiny_wallet) {
|
||||
if (state.user_status === "approved" && !state.mutiny_wallet && !state.deleting) {
|
||||
console.log("running setup node manager...")
|
||||
actions.setupMutinyWallet().then(() => console.log("node manager setup done"))
|
||||
}
|
||||
@@ -152,4 +165,4 @@ export function useMegaStore() {
|
||||
throw new Error("useMegaStore: cannot find a MegaStoreContext")
|
||||
}
|
||||
return context;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export default defineConfig({
|
||||
},
|
||||
optimizeDeps: {
|
||||
// Don't want vite to bundle these late during dev causing reload
|
||||
include: ["qr-scanner", "nostr-tools", "class-variance-authority"],
|
||||
include: ["qr-scanner", "nostr-tools", "class-variance-authority", "@kobalte/core", "@solid-primitives/upload"],
|
||||
// This is necessary because otherwise `vite dev` can't find the wasm
|
||||
exclude: ["@mutinywallet/mutiny-wasm", "@mutinywallet/waila-wasm"],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user