diff --git a/electron/app/main.ts b/electron/app/main.ts index 25547d4a..75df3a61 100644 --- a/electron/app/main.ts +++ b/electron/app/main.ts @@ -186,7 +186,13 @@ app.whenReady().then(async () => { // Single installer: checks LibreOffice and Chrome; if either is missing, shows one // window that installs them one after another. Resolves when the window closes. - await checkDependenciesBeforeWindow(); + const setupCompleted = await checkDependenciesBeforeWindow(); + if (!setupCompleted) { + // Block app usage when required setup is not completed. + win?.destroy(); + app.quit(); + return; + } // Update startup status after setup (user may have installed one or both) const [loResult, chromeOk] = await Promise.all([ diff --git a/electron/app/utils/setup-dependencies.ts b/electron/app/utils/setup-dependencies.ts index 2b142b9b..5f99f13b 100644 --- a/electron/app/utils/setup-dependencies.ts +++ b/electron/app/utils/setup-dependencies.ts @@ -28,9 +28,10 @@ export function getSetupStatus(): SetupStatus | null { /** * Checks LibreOffice and Chrome. If both are present, returns immediately. * If either is missing, opens one installer window that runs LibreOffice - * then Chrome in sequence. Resolves when the window closes (all done or skipped). + * then Chrome in sequence. Returns true only when all required dependencies + * are installed; false when the installer is closed/skipped before completion. */ -export async function checkDependenciesBeforeWindow(): Promise { +export async function checkDependenciesBeforeWindow(): Promise { const [loResult, chromeInstalled] = await Promise.all([ isLibreOfficeInstalled(), isChromeInstalled(), @@ -40,7 +41,7 @@ export async function checkDependenciesBeforeWindow(): Promise { const needsChrome = !chromeInstalled; if (!needsLibreOffice && !needsChrome) { - return; + return true; } currentSetupStatus = { @@ -50,7 +51,15 @@ export async function checkDependenciesBeforeWindow(): Promise { await showSetupInstallerWindow(); + // Re-check after installer closes; setup can only proceed when all + // required dependencies are actually installed. + const [postLoResult, postChromeInstalled] = await Promise.all([ + isLibreOfficeInstalled(), + isChromeInstalled(), + ]); + currentSetupStatus = null; + return postLoResult.installed && postChromeInstalled; } /**