|
3 | 3 | import { beforeNavigate, replaceState } from "$app/navigation"; |
4 | 4 | import { page, updated } from "$app/state"; |
5 | 5 | import { initDisabledPacks, initFavorites, initInternalState, initPreferences, initRecentSearches, initTheme, initWikiOrder, PacksContext, setHoverContext, setMobileContext, setPacksContext } from "$ctx"; |
| 6 | + import { initInternalPreferences } from "$ctx/internal-preferences.svelte"; |
6 | 7 | import Header from "$lib/components/header/Header.svelte"; |
7 | 8 | import { CommandPalette, PerformanceMode } from "$lib/components/misc"; |
8 | 9 | import ThemeEditor from "$lib/components/theme-editor/ThemeEditor.svelte"; |
|
11 | 12 | import { getPacks } from "$lib/shared/api/skycrypt-api.remote"; |
12 | 13 | import { parseThemeFromURL } from "$lib/shared/themes/sharing"; |
13 | 14 | import { cn } from "$lib/shared/utils"; |
| 15 | + import SurveyNotice from "$src/lib/components/notices/SurveyNotice.svelte"; |
14 | 16 | import Wifi from "@lucide/svelte/icons/wifi"; |
15 | 17 | import WifiOff from "@lucide/svelte/icons/wifi-off"; |
16 | 18 | import { Tooltip } from "bits-ui"; |
| 19 | + import { differenceInHours } from "date-fns"; |
17 | 20 | import { onMount, type Snippet } from "svelte"; |
18 | 21 | import SvelteSeo from "svelte-seo"; |
19 | 22 | import { toast, Toaster, type ToasterProps } from "svelte-sonner"; |
|
30 | 33 | let commandLoading = $state(false); |
31 | 34 | const { ign } = $derived(page.params); |
32 | 35 | const preferences = initPreferences(); |
| 36 | + const internalPreferences = initInternalPreferences(); |
33 | 37 | const themeContext = initTheme(); |
34 | 38 | const internalState = initInternalState(); |
35 | 39 | const position = writable<ToasterProps["position"]>("bottom-right"); |
|
163 | 167 |
|
164 | 168 | if (packsData) packs.packs = packsData; |
165 | 169 | }); |
| 170 | +
|
| 171 | + // TODO: Remove after the survey is done |
| 172 | + $effect(() => { |
| 173 | + const surveyPrefs = internalPreferences?.skycryptSurvey; |
| 174 | + if (!surveyPrefs) return; |
| 175 | +
|
| 176 | + const dismissedAt = surveyPrefs.dismissedAt ? new Date(surveyPrefs.dismissedAt) : null; |
| 177 | + const confirmedAt = surveyPrefs.confirmedAt ? new Date(surveyPrefs.confirmedAt) : null; |
| 178 | + const now = new Date(); |
| 179 | +
|
| 180 | + const isDismissedExpired = dismissedAt == null || differenceInHours(now, dismissedAt) > 12; |
| 181 | + const isConfirmedExpired = confirmedAt == null || differenceInHours(now, confirmedAt) > 12; |
| 182 | +
|
| 183 | + if (isDismissedExpired && isConfirmedExpired) { |
| 184 | + toast.custom(SurveyNotice, { |
| 185 | + id: "survey-notice", |
| 186 | + important: true, |
| 187 | + duration: Number.POSITIVE_INFINITY, |
| 188 | + position: "bottom-center" |
| 189 | + }); |
| 190 | + } |
| 191 | + }); |
166 | 192 | </script> |
167 | 193 |
|
168 | 194 | <svelte:document onkeydown={handleKeydown} /> |
|
0 commit comments