Move sidebar and offline imports to lazy loading
This commit is contained in:
+5
-1
@@ -4,7 +4,6 @@ import { safeCreateIcons } from './utils.js';
|
|||||||
import { showToast, closeHeaderMenu } from './ui.js';
|
import { showToast, closeHeaderMenu } from './ui.js';
|
||||||
import { t, getLocale, setLocale } from './i18n.js';
|
import { t, getLocale, setLocale } from './i18n.js';
|
||||||
import { showWelcome } from './viewer.js';
|
import { showWelcome } from './viewer.js';
|
||||||
import { loadVaults, loadTags } from './sidebar.js';
|
|
||||||
|
|
||||||
// ── Global logout handler for header dropdown onclick ────────────────────
|
// ── Global logout handler for header dropdown onclick ────────────────────
|
||||||
// Defined at module top level so it's always available, even if
|
// Defined at module top level so it's always available, even if
|
||||||
@@ -317,10 +316,15 @@ function initLoginForm() {
|
|||||||
|
|
||||||
// Load app data after successful login
|
// Load app data after successful login
|
||||||
try {
|
try {
|
||||||
|
// Dynamic imports to avoid circular dependency with sidebar.js
|
||||||
|
const { loadVaults, loadTags } = await import('./sidebar.js');
|
||||||
await Promise.all([loadVaults(), loadTags()]);
|
await Promise.all([loadVaults(), loadTags()]);
|
||||||
// Start SSE sync now that auth cookie is set (dynamic import to avoid circular dep)
|
// Start SSE sync now that auth cookie is set (dynamic import to avoid circular dep)
|
||||||
const { IndexUpdateManager } = await import('./sync.js');
|
const { IndexUpdateManager } = await import('./sync.js');
|
||||||
IndexUpdateManager.connect();
|
IndexUpdateManager.connect();
|
||||||
|
// Sync offline file index now that we're authenticated
|
||||||
|
const { syncFileIndexFromServer } = await import('./offline.js');
|
||||||
|
syncFileIndexFromServer();
|
||||||
// Show dashboard
|
// Show dashboard
|
||||||
showWelcome();
|
showWelcome();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
+12
-3
@@ -2,7 +2,7 @@
|
|||||||
import { state } from './state.js';
|
import { state } from './state.js';
|
||||||
import { t } from './i18n.js';
|
import { t } from './i18n.js';
|
||||||
import { showToast } from './ui.js';
|
import { showToast } from './ui.js';
|
||||||
import { api } from './auth.js';
|
import { api, AuthManager } from './auth.js';
|
||||||
import { loadVaults, loadTags, refreshTagsForContext, refreshSidebarTreePreservingState } from './sidebar.js';
|
import { loadVaults, loadTags, refreshTagsForContext, refreshSidebarTreePreservingState } from './sidebar.js';
|
||||||
import { loadRecentFiles, initAboutModal } from './config.js';
|
import { loadRecentFiles, initAboutModal } from './config.js';
|
||||||
import { openFile } from './viewer.js';
|
import { openFile } from './viewer.js';
|
||||||
@@ -591,8 +591,17 @@ export function init() {
|
|||||||
initOffline();
|
initOffline();
|
||||||
initThemes();
|
initThemes();
|
||||||
initAboutModal();
|
initAboutModal();
|
||||||
// Sync file index after a short delay (let vaults load first)
|
// Sync file index after a short delay (let vaults load first).
|
||||||
setTimeout(() => syncFileIndexFromServer(), 3000);
|
// Gate on auth at execution time (not scheduling time) so that
|
||||||
|
// initAuth() has a chance to complete and set _authEnabled / token.
|
||||||
|
// The login handler triggers syncFileIndexFromServer explicitly on
|
||||||
|
// fresh login, so we only do it here for already-authenticated or
|
||||||
|
// auth-disabled sessions.
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!AuthManager._authEnabled || AuthManager.getToken()) {
|
||||||
|
syncFileIndexFromServer();
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
initDashboardTabs();
|
initDashboardTabs();
|
||||||
|
|
||||||
// Listen for Forge editor rename events
|
// Listen for Forge editor rename events
|
||||||
|
|||||||
Reference in New Issue
Block a user