web: use setting store listener instead of directly using autoUpdates value

Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
01zulfi
2026-02-17 16:51:46 +05:00
parent 38ddbbf684
commit e4d36c5eba

View File

@@ -22,7 +22,7 @@ import { checkForUpdate } from "../utils/updater";
import { AppEventManager, AppEvents } from "../common/app-events";
import BaseStore from "../stores";
import createStore from "../common/store";
import { store as settingStore } from "../stores/setting-store";
import { useStore as useSettingStore } from "../stores/setting-store";
type CompletedUpdateStatus = { type: "completed"; version: string };
type DownloadingUpdateStatus = { type: "downloading"; progress: number };
@@ -103,8 +103,13 @@ export function useAutoUpdater() {
updateDownloadProgress
);
checkingForUpdate();
checkForUpdate(settingStore.get().autoUpdates).catch(console.error);
const settingStoreUnsub = useSettingStore.subscribe(
(s) => s.autoUpdates,
(autoUpdates) => {
checkingForUpdate();
checkForUpdate(autoUpdates).catch(console.error);
}
);
return () => {
checkingForUpdateEvent.unsubscribe();
@@ -112,6 +117,7 @@ export function useAutoUpdater() {
updateNotAvailableEvent.unsubscribe();
updateCompletedEvent.unsubscribe();
updateProgressEvent.unsubscribe();
settingStoreUnsub();
};
}, []);