electron: Fix initial sync (closes #284)

Apparently the issue was caused by options_init which for Electron was
attempting to read the theme asynchronously. That's why it didn't cause
issues on the server build.
This commit is contained in:
Elian Doran
2024-07-29 20:41:28 +03:00
parent bc5a1de9b7
commit 99ca701a5c
3 changed files with 19 additions and 15 deletions

View File

@@ -16,7 +16,7 @@ interface NotSyncedOpts {
syncProxy?: string;
}
async function initNotSyncedOptions(initialized: boolean, opts: NotSyncedOpts = {}) {
async function initNotSyncedOptions(initialized: boolean, theme: string, opts: NotSyncedOpts = {}) {
optionService.createOption('openNoteContexts', JSON.stringify([
{
notePath: 'root',
@@ -32,15 +32,7 @@ async function initNotSyncedOptions(initialized: boolean, opts: NotSyncedOpts =
optionService.createOption('initialized', initialized ? 'true' : 'false', false);
optionService.createOption('lastSyncedPull', '0', false);
optionService.createOption('lastSyncedPush', '0', false);
let theme = 'dark'; // default based on the poll in https://github.com/zadam/trilium/issues/2516
if (utils.isElectron()) {
const {nativeTheme} = await import("electron");
theme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
}
optionService.createOption('lastSyncedPush', '0', false);
optionService.createOption('theme', theme, false);