Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

desktop: disable update checker if auto updates off (#9302)

01zulfi93d1319b2525
diff --git a/apps/web/src/common/desktop-bridge/index.desktop.ts b/apps/web/src/common/desktop-bridge/index.desktop.ts
index 22de1888e..04ea973f6 100644
--- a/apps/web/src/common/desktop-bridge/index.desktop.ts
+++ b/apps/web/src/common/desktop-bridge/index.desktop.ts
@@ -26,6 +26,7 @@ import { checkForUpdate } from "../../utils/updater";
import { showToast } from "../../utils/toast";
import { db } from "../db";
import { logManager } from "@notesnook/core";
+import { store as settingStore } from "../../stores/setting-store";
export const desktop: ReturnType<typeof createTRPCProxyClient<AppRouter>> =
createTRPCProxyClient<AppRouter>({
@@ -78,7 +79,7 @@ function attachListeners() {
// });
TaskScheduler.register("updateCheck", "0 0 */12 * * * *", () => {
- checkForUpdate();
+ checkForUpdate(settingStore.get().autoUpdates);
});
}
diff --git a/apps/web/src/hooks/use-auto-updater.ts b/apps/web/src/hooks/use-auto-updater.ts
index 80b19b05e..870f13d3e 100644
--- a/apps/web/src/hooks/use-auto-updater.ts
+++ b/apps/web/src/hooks/use-auto-updater.ts
@@ -18,11 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useEffect } from "react";
-
import { checkForUpdate } from "../utils/updater";
import { AppEventManager, AppEvents } from "../common/app-events";
import BaseStore from "../stores";
import createStore from "../common/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().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();
};
}, []);
diff --git a/apps/web/src/stores/setting-store.ts b/apps/web/src/stores/setting-store.ts
index f08cc4efb..ab0c3240c 100644
--- a/apps/web/src/stores/setting-store.ts
+++ b/apps/web/src/stores/setting-store.ts
@@ -87,7 +87,7 @@ class SettingStore extends BaseStore<SettingStore> {
ImageCompressionOptions.ASK_EVERY_TIME
);
desktopIntegrationSettings?: DesktopIntegration;
- autoUpdates = true;
+ autoUpdates = false;
isFlatpak = false;
isSnap = false;
proxyRules?: string;
diff --git a/apps/web/src/utils/updater.ts b/apps/web/src/utils/updater.ts
index b0052defa..fc1883de9 100644
--- a/apps/web/src/utils/updater.ts
+++ b/apps/web/src/utils/updater.ts
@@ -21,9 +21,12 @@ import { AppEventManager, AppEvents } from "../common/app-events";
import { desktop } from "../common/desktop-bridge";
import { appVersion, getServiceWorkerVersion } from "./version";
-export async function checkForUpdate() {
- if (IS_DESKTOP_APP) await desktop?.updater.check.query().catch(console.error);
- else {
+export async function checkForUpdate(checkOnDesktop = true) {
+ if (IS_DESKTOP_APP && checkOnDesktop) {
+ await desktop?.updater.check.query().catch(console.error);
+ }
+
+ if (!IS_DESKTOP_APP) {
AppEventManager.publish(AppEvents.checkingForUpdate);
const registrations =