|
1 | 1 | <script lang="ts"> |
2 | | -import { goto } from "$app/navigation"; |
3 | | -import { SettingsNavigationBtn } from "$lib/fragments"; |
4 | | -import type { GlobalState } from "$lib/global"; |
5 | | -import { runtime } from "$lib/global/runtime.svelte"; |
6 | | -import { BottomSheet, ButtonAction } from "$lib/ui"; |
7 | | -import { |
8 | | - Key01Icon, |
9 | | - LanguageSquareIcon, |
10 | | - Link02Icon, |
11 | | - LockPasswordIcon, |
12 | | - PinCodeIcon, |
13 | | - Shield01Icon, |
14 | | -} from "@hugeicons/core-free-icons"; |
15 | | -import { getContext } from "svelte"; |
16 | | -import { onDestroy } from "svelte"; |
17 | | -
|
18 | | -const getGlobalState = getContext<() => GlobalState>("globalState"); |
19 | | -const setGlobalState = |
20 | | - getContext<(value: GlobalState) => void>("setGlobalState"); |
21 | | -let globalState = getGlobalState(); |
22 | | -
|
23 | | -let isDeleteConfirmationOpen = $state(false); |
24 | | -let isFinalConfirmationOpen = $state(false); |
25 | | -
|
26 | | -// Hidden eVault profile retry functionality |
27 | | -let tapCount = $state(0); |
28 | | -let lastTapTime = $state(0); |
29 | | -let isRetrying = $state(false); |
30 | | -let retryMessage = $state(""); |
31 | | -let timeoutId: ReturnType<typeof setTimeout> | null = null; |
32 | | -
|
33 | | -function showDeleteConfirmation() { |
34 | | - isDeleteConfirmationOpen = true; |
35 | | -} |
36 | | -
|
37 | | -function confirmDelete() { |
38 | | - isDeleteConfirmationOpen = false; |
39 | | - isFinalConfirmationOpen = true; |
40 | | -} |
41 | | -
|
42 | | -async function nukeWallet() { |
43 | | - const newGlobalState = await globalState.reset(); |
44 | | - setGlobalState(newGlobalState); |
45 | | - globalState = newGlobalState; |
46 | | - goto("/onboarding"); |
47 | | -} |
48 | | -
|
49 | | -async function cancelDelete() { |
50 | | - isDeleteConfirmationOpen = false; |
51 | | - isFinalConfirmationOpen = false; |
52 | | - await goto("/main"); |
53 | | -} |
54 | | -
|
55 | | -// Cleanup on unmount |
56 | | -onDestroy(() => { |
57 | | - if (timeoutId) clearTimeout(timeoutId); |
58 | | -}); |
59 | | -
|
60 | | -async function handleVersionTap() { |
61 | | - const now = Date.now(); |
62 | | -
|
63 | | - // Reset if more than 3s between taps |
64 | | - if (now - lastTapTime > 3000) { |
65 | | - tapCount = 0; |
| 2 | + import { goto } from "$app/navigation"; |
| 3 | + import { SettingsNavigationBtn } from "$lib/fragments"; |
| 4 | + import type { GlobalState } from "$lib/global"; |
| 5 | + import { runtime } from "$lib/global/runtime.svelte"; |
| 6 | + import { BottomSheet, ButtonAction } from "$lib/ui"; |
| 7 | + import { |
| 8 | + Key01Icon, |
| 9 | + LanguageSquareIcon, |
| 10 | + Link02Icon, |
| 11 | + LockPasswordIcon, |
| 12 | + PinCodeIcon, |
| 13 | + Shield01Icon, |
| 14 | + } from "@hugeicons/core-free-icons"; |
| 15 | + import { getContext } from "svelte"; |
| 16 | + import { onDestroy } from "svelte"; |
| 17 | +
|
| 18 | + const getGlobalState = getContext<() => GlobalState>("globalState"); |
| 19 | + const setGlobalState = |
| 20 | + getContext<(value: GlobalState) => void>("setGlobalState"); |
| 21 | + let globalState = getGlobalState(); |
| 22 | +
|
| 23 | + let isDeleteConfirmationOpen = $state(false); |
| 24 | + let isFinalConfirmationOpen = $state(false); |
| 25 | +
|
| 26 | + // Hidden eVault profile retry functionality |
| 27 | + let tapCount = $state(0); |
| 28 | + let lastTapTime = $state(0); |
| 29 | + let isRetrying = $state(false); |
| 30 | + let retryMessage = $state(""); |
| 31 | + let timeoutId: ReturnType<typeof setTimeout> | null = null; |
| 32 | +
|
| 33 | + function showDeleteConfirmation() { |
| 34 | + isDeleteConfirmationOpen = true; |
66 | 35 | } |
67 | 36 |
|
68 | | - tapCount++; |
69 | | - lastTapTime = now; |
| 37 | + function confirmDelete() { |
| 38 | + isDeleteConfirmationOpen = false; |
| 39 | + isFinalConfirmationOpen = true; |
| 40 | + } |
70 | 41 |
|
71 | | - // Show feedback after 5 taps |
72 | | - if (tapCount >= 5) { |
73 | | - retryMessage = `Taps: ${tapCount}/10`; |
| 42 | + async function nukeWallet() { |
| 43 | + const newGlobalState = await globalState.reset(); |
| 44 | + setGlobalState(newGlobalState); |
| 45 | + globalState = newGlobalState; |
| 46 | + goto("/onboarding"); |
74 | 47 | } |
75 | 48 |
|
76 | | - // Trigger hidden action at 10 taps |
77 | | - if (tapCount === 10) { |
78 | | - isRetrying = true; |
79 | | - retryMessage = "Retrying eVault profile setup..."; |
| 49 | + async function cancelDelete() { |
| 50 | + isDeleteConfirmationOpen = false; |
| 51 | + isFinalConfirmationOpen = false; |
| 52 | + await goto("/main"); |
| 53 | + } |
80 | 54 |
|
81 | | - try { |
82 | | - await globalState.vaultController.retryProfileCreation(); |
83 | | - retryMessage = "✅ eVault profile setup completed successfully!"; |
84 | | -
|
85 | | - // Clear previous timeout if exists |
86 | | - if (timeoutId) clearTimeout(timeoutId); |
87 | | -
|
88 | | - timeoutId = setTimeout(() => { |
89 | | - tapCount = 0; |
90 | | - retryMessage = ""; |
91 | | - isRetrying = false; |
92 | | - }, 3000); |
93 | | - } catch (error) { |
94 | | - console.error("Failed to retry eVault profile setup:", error); |
95 | | - retryMessage = |
96 | | - "❌ Failed to setup eVault profile. Check console for details."; |
97 | | -
|
98 | | - // Clear previous timeout if exists |
99 | | - if (timeoutId) clearTimeout(timeoutId); |
100 | | -
|
101 | | - timeoutId = setTimeout(() => { |
102 | | - tapCount = 0; |
103 | | - retryMessage = ""; |
104 | | - isRetrying = false; |
105 | | - }, 5000); |
| 55 | + // Cleanup on unmount |
| 56 | + onDestroy(() => { |
| 57 | + if (timeoutId) clearTimeout(timeoutId); |
| 58 | + }); |
| 59 | +
|
| 60 | + async function handleVersionTap() { |
| 61 | + const now = Date.now(); |
| 62 | +
|
| 63 | + // Reset if more than 3s between taps |
| 64 | + if (now - lastTapTime > 3000) { |
| 65 | + tapCount = 0; |
| 66 | + } |
| 67 | +
|
| 68 | + tapCount++; |
| 69 | + lastTapTime = now; |
| 70 | +
|
| 71 | + // Show feedback after 5 taps |
| 72 | + if (tapCount >= 5) { |
| 73 | + retryMessage = `Taps: ${tapCount}/10`; |
| 74 | + } |
| 75 | +
|
| 76 | + // Trigger hidden action at 10 taps |
| 77 | + if (tapCount === 10) { |
| 78 | + isRetrying = true; |
| 79 | + retryMessage = "Retrying eVault profile setup..."; |
| 80 | +
|
| 81 | + try { |
| 82 | + await globalState.vaultController.retryProfileCreation(); |
| 83 | + retryMessage = |
| 84 | + "✅ eVault profile setup completed successfully!"; |
| 85 | +
|
| 86 | + // Clear previous timeout if exists |
| 87 | + if (timeoutId) clearTimeout(timeoutId); |
| 88 | +
|
| 89 | + timeoutId = setTimeout(() => { |
| 90 | + tapCount = 0; |
| 91 | + retryMessage = ""; |
| 92 | + isRetrying = false; |
| 93 | + }, 3000); |
| 94 | + } catch (error) { |
| 95 | + console.error("Failed to retry eVault profile setup:", error); |
| 96 | + retryMessage = |
| 97 | + "❌ Failed to setup eVault profile. Check console for details."; |
| 98 | +
|
| 99 | + // Clear previous timeout if exists |
| 100 | + if (timeoutId) clearTimeout(timeoutId); |
| 101 | +
|
| 102 | + timeoutId = setTimeout(() => { |
| 103 | + tapCount = 0; |
| 104 | + retryMessage = ""; |
| 105 | + isRetrying = false; |
| 106 | + }, 5000); |
| 107 | + } |
106 | 108 | } |
107 | 109 | } |
108 | | -} |
109 | | -
|
110 | | -async function openPrivacy(e: Event) { |
111 | | - e.preventDefault(); |
112 | | - try { |
113 | | - const { openUrl } = await import("@tauri-apps/plugin-opener"); |
114 | | - await openUrl("https://metastate.foundation/"); |
115 | | - } catch { |
116 | | - window.location.href = "https://metastate.foundation/"; |
| 110 | +
|
| 111 | + async function openPrivacy(e: Event) { |
| 112 | + e.preventDefault(); |
| 113 | + try { |
| 114 | + const { openUrl } = await import("@tauri-apps/plugin-opener"); |
| 115 | + await openUrl("https://metastate.foundation/"); |
| 116 | + } catch { |
| 117 | + window.location.href = "https://metastate.foundation/"; |
| 118 | + } |
117 | 119 | } |
118 | | -} |
119 | 120 |
|
120 | | -$effect(() => { |
121 | | - runtime.header.title = "Settings"; |
122 | | -}); |
| 121 | + $effect(() => { |
| 122 | + runtime.header.title = "Settings"; |
| 123 | + }); |
123 | 124 | </script> |
124 | 125 |
|
125 | 126 | <main class="h-[80svh] flex flex-col justify-between"> |
@@ -161,7 +162,7 @@ $effect(() => { |
161 | 162 | onclick={handleVersionTap} |
162 | 163 | disabled={isRetrying} |
163 | 164 | > |
164 | | - Version v0.6.0.0 |
| 165 | + Version v0.7.0 |
165 | 166 | </button> |
166 | 167 |
|
167 | 168 | {#if retryMessage} |
@@ -197,8 +198,10 @@ $effect(() => { |
197 | 198 | <li>• This action cannot be undone</li> |
198 | 199 | </ul> |
199 | 200 | <div class="flex gap-3"> |
200 | | - <ButtonAction variant="soft" class="flex-1" callback={cancelDelete} |
201 | | - >Cancel</ButtonAction |
| 201 | + <ButtonAction |
| 202 | + variant="soft" |
| 203 | + class="flex-1" |
| 204 | + callback={cancelDelete}>Cancel</ButtonAction |
202 | 205 | > |
203 | 206 | <ButtonAction |
204 | 207 | variant="danger" |
@@ -230,8 +233,10 @@ $effect(() => { |
230 | 233 | Are you absolutely certain you want to proceed? |
231 | 234 | </p> |
232 | 235 | <div class="flex gap-3"> |
233 | | - <ButtonAction variant="soft" class="flex-1" callback={cancelDelete} |
234 | | - >Cancel</ButtonAction |
| 236 | + <ButtonAction |
| 237 | + variant="soft" |
| 238 | + class="flex-1" |
| 239 | + callback={cancelDelete}>Cancel</ButtonAction |
235 | 240 | > |
236 | 241 | <ButtonAction |
237 | 242 | variant="danger" |
|
0 commit comments