Compare commits

..

1 Commits

Author SHA1 Message Date
Marc Brooks 0cabdf51e7
Merge f23480792b into 6e1b84f39b 2025-11-07 13:25:11 +01:00
2 changed files with 12 additions and 23 deletions

View File

@ -603,9 +603,6 @@ export interface UpdateState {
updateErrorMessage: string | null; updateErrorMessage: string | null;
setUpdateErrorMessage: (errorMessage: string) => void; setUpdateErrorMessage: (errorMessage: string) => void;
shouldReload: boolean;
setShouldReload: (reloadRequired: boolean) => void;
} }
export const useUpdateStore = create<UpdateState>(set => ({ export const useUpdateStore = create<UpdateState>(set => ({
@ -643,9 +640,6 @@ export const useUpdateStore = create<UpdateState>(set => ({
updateErrorMessage: null, updateErrorMessage: null,
setUpdateErrorMessage: (errorMessage: string) => setUpdateErrorMessage: (errorMessage: string) =>
set({ updateErrorMessage: errorMessage }), set({ updateErrorMessage: errorMessage }),
shouldReload: false,
setShouldReload: (reloadRequired: boolean) => set({ shouldReload: reloadRequired }),
})); }));
export type UsbConfigModalViews = "updateUsbConfig" | "updateUsbConfigSuccess"; export type UsbConfigModalViews = "updateUsbConfig" | "updateUsbConfigSuccess";

View File

@ -18,24 +18,20 @@ export default function SettingsGeneralUpdateRoute() {
const location = useLocation(); const location = useLocation();
const { updateSuccess } = location.state || {}; const { updateSuccess } = location.state || {};
const { setModalView, otaState, shouldReload, setShouldReload } = useUpdateStore(); const { setModalView, otaState } = useUpdateStore();
const { send } = useJsonRpc(); const { send } = useJsonRpc();
const onClose = useCallback(async () => { const onClose = useCallback(async () => {
navigate(".."); // back to the devices.$id.settings page navigate(".."); // back to the devices.$id.settings page
// Add 1s delay between navigation and calling reload() to prevent reload from interrupting the navigation.
if (shouldReload) { await sleep(1000);
setShouldReload(false);
await sleep(1000); // Add 1s delay between navigation and calling reload() to prevent reload from interrupting the navigation.
window.location.reload(); // force a full reload to ensure the current device/cloud UI version is loaded window.location.reload(); // force a full reload to ensure the current device/cloud UI version is loaded
} }, [navigate]);
}, [navigate, setShouldReload, shouldReload]);
const onConfirmUpdate = useCallback(() => { const onConfirmUpdate = useCallback(() => {
setShouldReload(true);
send("tryUpdate", {}); send("tryUpdate", {});
setModalView("updating"); setModalView("updating");
}, [send, setModalView, setShouldReload]); }, [send, setModalView]);
useEffect(() => { useEffect(() => {
if (otaState.updating) { if (otaState.updating) {
@ -137,7 +133,6 @@ function LoadingState({
const { setModalView } = useUpdateStore(); const { setModalView } = useUpdateStore();
const progressBarRef = useRef<HTMLDivElement>(null); const progressBarRef = useRef<HTMLDivElement>(null);
useEffect(() => { useEffect(() => {
abortControllerRef.current = new AbortController(); abortControllerRef.current = new AbortController();
const signal = abortControllerRef.current.signal; const signal = abortControllerRef.current.signal;