Enhance app update checks with improved error handling and duplicate installation detection
Some checks reported errors
farmcontrol/farmcontrol-ui/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
farmcontrol/farmcontrol-ui/pipeline/head Something is wrong with the build of this commit
- Updated `AppUpdateProvider` to handle errors during startup checks for app updates and duplicate installations, improving robustness. - Refactored logic to ensure duplicate installation checks are integrated into the update process, providing clearer feedback to users. - Adjusted modal visibility conditions for duplicate installation prompts to streamline user experience.
This commit is contained in:
parent
c5d8d9cf70
commit
e32eda100a
@ -308,19 +308,29 @@ export const AppUpdateProvider = ({ children }) => {
|
||||
let cancelled = false
|
||||
|
||||
const runStartupChecks = async () => {
|
||||
let result = null
|
||||
|
||||
try {
|
||||
const result = await checkAppUpdateResult?.()
|
||||
result = await checkAppUpdateResult?.()
|
||||
if (!cancelled && result?.updated) {
|
||||
setCompletedUpdate(result)
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('[AppUpdateContext] Startup update check failed:', error)
|
||||
}
|
||||
|
||||
const installations = await checkDuplicateInstallations?.()
|
||||
try {
|
||||
const installations =
|
||||
result?.duplicates || (await checkDuplicateInstallations?.())
|
||||
if (!cancelled && installations?.duplicatePath) {
|
||||
setDuplicateInstall(installations)
|
||||
setDuplicatePromptOpen(true)
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('[AppUpdateContext] Startup update checks failed:', error)
|
||||
console.warn(
|
||||
'[AppUpdateContext] Duplicate installation check failed:',
|
||||
error
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -537,9 +547,7 @@ export const AppUpdateProvider = ({ children }) => {
|
||||
</Modal>
|
||||
<Modal
|
||||
title='Duplicate Installation Found'
|
||||
open={Boolean(
|
||||
duplicatePromptOpen && duplicateInstall && !completedUpdate
|
||||
)}
|
||||
open={Boolean(duplicatePromptOpen && duplicateInstall)}
|
||||
style={{ maxWidth: 480 }}
|
||||
centered
|
||||
closable={!removingDuplicate}
|
||||
|
||||
@ -7,6 +7,7 @@ import process from "node:process";
|
||||
import { Utils } from "electrobun/bun";
|
||||
import { launchMacInstaller } from "./macappupdate.js";
|
||||
import { launchWindowsInstaller } from "./winappupdate.js";
|
||||
import { checkForDuplicateInstallations } from "./check-duplicate-installations.js";
|
||||
import { scheduleAppRestart } from "./updater-runner.js";
|
||||
import { getAppSettings, setAppSettings } from "./store.js";
|
||||
|
||||
@ -266,10 +267,17 @@ export const checkForCompletedUpdate = async (mainWindow) => {
|
||||
normalizeEngine(current.engine),
|
||||
));
|
||||
|
||||
completedUpdateResult = { updated, previous, current };
|
||||
const duplicates = checkForDuplicateInstallations();
|
||||
|
||||
completedUpdateResult = { updated, previous, current, duplicates };
|
||||
} catch (error) {
|
||||
console.warn("[app-update] Failed to check for a completed update.", error);
|
||||
completedUpdateResult = { updated: false, previous: null, current: null };
|
||||
completedUpdateResult = {
|
||||
updated: false,
|
||||
previous: null,
|
||||
current: null,
|
||||
duplicates: checkForDuplicateInstallations(),
|
||||
};
|
||||
}
|
||||
|
||||
return completedUpdateResult;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user