|
9 | 9 | import IconLinkButton from "$lib/components/input/IconLinkButton/IconLinkButton.svelte"; |
10 | 10 | import Toaster from "$lib/components/messaging/Toaster/Toaster.svelte"; |
11 | 11 | import Blanket from "$lib/components/overlays/Blanket/Blanket.svelte"; |
| 12 | + import { appState, initTrackers } from "$lib/engines/appStateEngine.svelte.ts"; |
| 13 | + import { useShortcut } from "$lib/engines/shortcutEngine.svelte.ts"; |
| 14 | + import { currentTheme, setTheme } from "$lib/engines/themeEngine.svelte.ts"; |
| 15 | + import { createTranslationEngine } from "$lib/engines/translationEngine.svelte.ts"; |
12 | 16 | import { token } from "$lib/styles/designTokens.ts"; |
13 | 17 |
|
14 | | - import { useShortcut } from "../../../../lib/engines/shortcutEngine.svelte.ts"; |
15 | | - import { appState } from "../../../engines/appStateEngine.svelte.ts"; |
16 | | - import { currentTheme, setTheme } from "../../../engines/themeEngine.svelte.ts"; |
17 | | - import { createTranslationEngine } from "../../../engines/translationEngine.svelte.ts"; |
18 | 18 | import Anchor from "../Anchor/Anchor.svelte"; |
19 | 19 | import Flex from "../Flex/Flex.svelte"; |
20 | 20 | import Icon from "../Icon/Icon.svelte"; |
|
64 | 64 | console.log("buildTime: " + __DDS_INFO__.buildTime); |
65 | 65 | console.groupEnd(); |
66 | 66 |
|
67 | | - // Some notes: |
68 | | - // Read caches first of engines after rerun after auth completed??? |
69 | | - // Keep lastcommunicated value or smth that you dont refresh if newer then 10m |
| 67 | + // Multi-Account Auth: |
| 68 | + // - Storage: HttpOnly cookies named `token_${accountId}`. |
| 69 | + // - Request: Frontend sends `x-active-account: ${accountId}` header. |
| 70 | + // - Backend: Reads header, pulls the matching cookie, and validates that specific JWT. |
| 71 | +
|
| 72 | + // We dont need cache bcs we can just use the JWT and after refresh it. |
70 | 73 |
|
71 | 74 | try { |
72 | 75 | console.debug("[AppShell] Configuring translationEngine."); |
|
79 | 82 | console.debug("[AppShell] Configuring theme engine."); |
80 | 83 | setTheme("dark"); |
81 | 84 |
|
82 | | - // Vite connection |
83 | | - if (import.meta.hot) { |
84 | | - import.meta.hot.on("vite:ws:disconnect", () => { |
85 | | - appState.viteConnected = false; |
86 | | - }); |
87 | | -
|
88 | | - import.meta.hot.on("vite:ws:connect", () => { |
89 | | - appState.viteConnected = true; |
90 | | - }); |
91 | | - } else { |
92 | | - appState.viteConnected = false; |
93 | | - } |
94 | | -
|
95 | | - // Is mobile |
96 | | - const mediaQuery = window.matchMedia("(max-width: 768px)"); |
97 | | - appState.isMobile = mediaQuery.matches; |
98 | | -
|
99 | | - const handler = (e: MediaQueryListEvent) => { |
100 | | - appState.isMobile = e.matches; |
101 | | - }; |
102 | | - mediaQuery.addEventListener("change", handler); |
103 | | -
|
104 | | - return () => { |
105 | | - mediaQuery.removeEventListener("change", handler); |
106 | | - }; |
| 85 | + // AppStateEngine trackers |
| 86 | + initTrackers(); |
107 | 87 | }); |
108 | 88 |
|
109 | 89 | const toggleSidebar = useShortcut( |
|
135 | 115 | <div class="appshell {currentTheme.themeObject} {styles.base}" id="appshell"> |
136 | 116 | <div class={styles.container}> |
137 | 117 | <div class={styles.maincontainer}> |
138 | | - {#if appState.isDevelopmentBuild && !appState.viteConnected} |
| 118 | + {#if import.meta.env.DEV && !appState.viteConnected} |
139 | 119 | <Banner icon="sync_problem" appearance="danger"> |
140 | 120 | <b>Vite connection lost.</b> |
141 | 121 | Hot Module Reloading will be unavailable until reconnected. |
142 | 122 | </Banner> |
143 | 123 | {/if} |
| 124 | + {#if appState.isOffline} |
| 125 | + <Banner icon="cloud_alert" appearance="danger"> |
| 126 | + <b>Connection lost.</b> |
| 127 | + We have lost the connection with Davidnet. Please check your internet connection. |
| 128 | + </Banner> |
| 129 | + {/if} |
144 | 130 | {@render banners?.()} |
145 | 131 |
|
146 | 132 | <Flex height="100%" width="100%" direction="column"> |
|
0 commit comments