Enhance dependency check to block app usage if setup is incomplete

This commit is contained in:
sudipnext 2026-03-15 16:08:24 +05:45
parent f105c89b89
commit 813ed998f5
2 changed files with 19 additions and 4 deletions

View file

@ -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([

View file

@ -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<void> {
export async function checkDependenciesBeforeWindow(): Promise<boolean> {
const [loResult, chromeInstalled] = await Promise.all([
isLibreOfficeInstalled(),
isChromeInstalled(),
@ -40,7 +41,7 @@ export async function checkDependenciesBeforeWindow(): Promise<void> {
const needsChrome = !chromeInstalled;
if (!needsLibreOffice && !needsChrome) {
return;
return true;
}
currentSetupStatus = {
@ -50,7 +51,15 @@ export async function checkDependenciesBeforeWindow(): Promise<void> {
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;
}
/**