refactor: move dashboard screens into shell routes

This commit is contained in:
2026-04-17 13:20:00 +01:00
parent e97a54ac8d
commit fac6409ec4
16 changed files with 113 additions and 21 deletions

View File

@@ -55,6 +55,9 @@ let initPromise = null;
let socket = null;
let pollInterval = null;
let socketHeartbeatInterval = null;
const handleBeforeUnload = () => {
void cleanupConnectionState();
};
let clientVideoElement = null;
@@ -839,7 +842,13 @@ const invalidateSavedDevice = async (message, options = {}) => {
const enforceRouteForSession = () => {
const state = getAppState();
const page = pageFromPath(window.location.pathname);
setAppState({ page });
const initialPage =
page === 'app'
? state.deviceToken
? getHomePageKeyForRole(state.device?.role)
: 'onboarding'
: page;
setAppState({ page: initialPage });
if (!state.session) {
if (page !== 'auth') {
@@ -856,7 +865,7 @@ const enforceRouteForSession = () => {
}
const expectedHome = getHomePageKeyForRole(state.device?.role);
if ((page === 'auth' || page === 'onboarding') && expectedHome) {
if ((page === 'auth' || page === 'onboarding' || page === 'app') && expectedHome) {
navigateToScreen('home', { replace: true, role: state.device?.role });
return;
}
@@ -903,9 +912,7 @@ const init = async () => {
void refreshCameraInputDevices();
applyMotionDetectionReadiness();
window.addEventListener('beforeunload', () => {
void cleanupConnectionState();
});
window.addEventListener('beforeunload', handleBeforeUnload);
initialized = true;
})().finally(() => {
@@ -923,6 +930,7 @@ const destroy = async () => {
if (typeof document !== 'undefined') {
document.removeEventListener('visibilitychange', onVisibilityChange);
}
window.removeEventListener('beforeunload', handleBeforeUnload);
initialized = false;
await cleanupConnectionState();
};
@@ -955,6 +963,10 @@ const actions = {
patchAppState((state) => ({ isRegistering: !state.isRegistering }));
},
setAuthMode(isRegistering) {
setAppState({ isRegistering });
},
async submitAuth() {
const state = getAppState();
const { email, password, name } = state.authForm;