|
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 { ButtonAction, Drawer } from "$lib/ui"; |
7 | | - import { |
8 | | - Key01Icon, |
9 | | - LanguageSquareIcon, |
10 | | - Link02Icon, |
11 | | - PinCodeIcon, |
12 | | - Shield01Icon, |
13 | | - } from "@hugeicons/core-free-icons"; |
14 | | - import { getContext } from "svelte"; |
15 | | -
|
16 | | - const getGlobalState = getContext<() => GlobalState>("globalState"); |
17 | | - const setGlobalState = |
18 | | - getContext<(value: GlobalState) => void>("setGlobalState"); |
19 | | - let globalState = getGlobalState(); |
20 | | -
|
21 | | - let isDeleteConfirmationOpen = $state(false); |
22 | | - let isFinalConfirmationOpen = $state(false); |
23 | | -
|
24 | | - // Hidden eVault profile retry functionality |
25 | | - let tapCount = $state(0); |
26 | | - let lastTapTime = $state(0); |
27 | | - let isRetrying = $state(false); |
28 | | - let retryMessage = $state(""); |
29 | | -
|
30 | | - function showDeleteConfirmation() { |
31 | | - isDeleteConfirmationOpen = true; |
| 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 { ButtonAction, Drawer } from "$lib/ui"; |
| 7 | +import { |
| 8 | + Key01Icon, |
| 9 | + LanguageSquareIcon, |
| 10 | + Link02Icon, |
| 11 | + PinCodeIcon, |
| 12 | + Shield01Icon, |
| 13 | +} from "@hugeicons/core-free-icons"; |
| 14 | +import { getContext } from "svelte"; |
| 15 | +
|
| 16 | +const getGlobalState = getContext<() => GlobalState>("globalState"); |
| 17 | +const setGlobalState = |
| 18 | + getContext<(value: GlobalState) => void>("setGlobalState"); |
| 19 | +let globalState = getGlobalState(); |
| 20 | +
|
| 21 | +let isDeleteConfirmationOpen = $state(false); |
| 22 | +let isFinalConfirmationOpen = $state(false); |
| 23 | +
|
| 24 | +// Hidden eVault profile retry functionality |
| 25 | +let tapCount = $state(0); |
| 26 | +let lastTapTime = $state(0); |
| 27 | +let isRetrying = $state(false); |
| 28 | +let retryMessage = $state(""); |
| 29 | +
|
| 30 | +function showDeleteConfirmation() { |
| 31 | + isDeleteConfirmationOpen = true; |
| 32 | +} |
| 33 | +
|
| 34 | +function confirmDelete() { |
| 35 | + isDeleteConfirmationOpen = false; |
| 36 | + isFinalConfirmationOpen = true; |
| 37 | +} |
| 38 | +
|
| 39 | +async function nukeWallet() { |
| 40 | + const newGlobalState = await globalState.reset(); |
| 41 | + setGlobalState(newGlobalState); |
| 42 | + globalState = newGlobalState; |
| 43 | + goto("/onboarding"); |
| 44 | +} |
| 45 | +
|
| 46 | +function cancelDelete() { |
| 47 | + isDeleteConfirmationOpen = false; |
| 48 | + isFinalConfirmationOpen = false; |
| 49 | +} |
| 50 | +
|
| 51 | +async function handleVersionTap() { |
| 52 | + const now = Date.now(); |
| 53 | +
|
| 54 | + // Reset counter if more than 3 seconds between taps |
| 55 | + if (now - lastTapTime > 3000) { |
| 56 | + tapCount = 0; |
32 | 57 | } |
33 | 58 |
|
34 | | - function confirmDelete() { |
35 | | - isDeleteConfirmationOpen = false; |
36 | | - isFinalConfirmationOpen = true; |
37 | | - } |
38 | | -
|
39 | | - async function nukeWallet() { |
40 | | - const newGlobalState = await globalState.reset(); |
41 | | - setGlobalState(newGlobalState); |
42 | | - globalState = newGlobalState; |
43 | | - goto("/onboarding"); |
44 | | - } |
| 59 | + tapCount++; |
| 60 | + lastTapTime = now; |
45 | 61 |
|
46 | | - function cancelDelete() { |
47 | | - isDeleteConfirmationOpen = false; |
48 | | - isFinalConfirmationOpen = false; |
| 62 | + // Show tap count feedback (only visible to user) |
| 63 | + if (tapCount >= 5) { |
| 64 | + retryMessage = `Taps: ${tapCount}/10`; |
49 | 65 | } |
50 | 66 |
|
51 | | - async function handleVersionTap() { |
52 | | - const now = Date.now(); |
53 | | -
|
54 | | - // Reset counter if more than 3 seconds between taps |
55 | | - if (now - lastTapTime > 3000) { |
56 | | - tapCount = 0; |
57 | | - } |
58 | | -
|
59 | | - tapCount++; |
60 | | - lastTapTime = now; |
61 | | -
|
62 | | - // Show tap count feedback (only visible to user) |
63 | | - if (tapCount >= 5) { |
64 | | - retryMessage = `Taps: ${tapCount}/10`; |
65 | | - } |
66 | | -
|
67 | | - // Trigger eVault profile retry after 10 taps |
68 | | - if (tapCount === 10) { |
69 | | - isRetrying = true; |
70 | | - retryMessage = "Retrying eVault profile setup..."; |
71 | | -
|
72 | | - try { |
73 | | - await globalState.vaultController.retryProfileCreation(); |
74 | | - retryMessage = |
75 | | - "✅ eVault profile setup completed successfully!"; |
76 | | -
|
77 | | - // Reset after success |
78 | | - setTimeout(() => { |
79 | | - tapCount = 0; |
80 | | - retryMessage = ""; |
81 | | - isRetrying = false; |
82 | | - }, 3000); |
83 | | - } catch (error) { |
84 | | - console.error("Failed to retry eVault profile setup:", error); |
85 | | - retryMessage = |
86 | | - "❌ Failed to setup eVault profile. Check console for details."; |
87 | | -
|
88 | | - // Reset after error |
89 | | - setTimeout(() => { |
90 | | - tapCount = 0; |
91 | | - retryMessage = ""; |
92 | | - isRetrying = false; |
93 | | - }, 5000); |
94 | | - } |
| 67 | + // Trigger eVault profile retry after 10 taps |
| 68 | + if (tapCount === 10) { |
| 69 | + isRetrying = true; |
| 70 | + retryMessage = "Retrying eVault profile setup..."; |
| 71 | +
|
| 72 | + try { |
| 73 | + await globalState.vaultController.retryProfileCreation(); |
| 74 | + retryMessage = "✅ eVault profile setup completed successfully!"; |
| 75 | +
|
| 76 | + // Reset after success |
| 77 | + setTimeout(() => { |
| 78 | + tapCount = 0; |
| 79 | + retryMessage = ""; |
| 80 | + isRetrying = false; |
| 81 | + }, 3000); |
| 82 | + } catch (error) { |
| 83 | + console.error("Failed to retry eVault profile setup:", error); |
| 84 | + retryMessage = |
| 85 | + "❌ Failed to setup eVault profile. Check console for details."; |
| 86 | +
|
| 87 | + // Reset after error |
| 88 | + setTimeout(() => { |
| 89 | + tapCount = 0; |
| 90 | + retryMessage = ""; |
| 91 | + isRetrying = false; |
| 92 | + }, 5000); |
95 | 93 | } |
96 | 94 | } |
| 95 | +} |
97 | 96 |
|
98 | | - $effect(() => { |
99 | | - runtime.header.title = "Settings"; |
100 | | - }); |
| 97 | +$effect(() => { |
| 98 | + runtime.header.title = "Settings"; |
| 99 | +}); |
101 | 100 | </script> |
102 | 101 |
|
103 | 102 | <main> |
|
0 commit comments