Move sidebar and offline imports to lazy loading
CI / lint (push) Failing after 21s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / e2e (push) Has been skipped
CI / security (push) Failing after 10s

This commit is contained in:
2026-07-20 22:31:07 -04:00
parent 790f97e501
commit c3c5f11e9b
2 changed files with 17 additions and 4 deletions
+12 -3
View File
@@ -2,7 +2,7 @@
import { state } from './state.js';
import { t } from './i18n.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 { loadRecentFiles, initAboutModal } from './config.js';
import { openFile } from './viewer.js';
@@ -591,8 +591,17 @@ export function init() {
initOffline();
initThemes();
initAboutModal();
// Sync file index after a short delay (let vaults load first)
setTimeout(() => syncFileIndexFromServer(), 3000);
// Sync file index after a short delay (let vaults load first).
// 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();
// Listen for Forge editor rename events