A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
desktop: fix multiple updates running simultaneously
Abdullah Attae6d8401c5618
diff --git a/apps/desktop/src/api/updater.ts b/apps/desktop/src/api/updater.tsindex accd9d2a6..1f5768e8e 100644--- a/apps/desktop/src/api/updater.ts+++ b/apps/desktop/src/api/updater.ts@@ -29,19 +29,37 @@ type Progress = { percent: number };const t = initTRPC.create();let cancellationToken: CancellationToken | undefined = undefined;+let downloadTimeout: NodeJS.Timeout | undefined = undefined;export const updaterRouter = t.router({autoUpdates: t.procedure.query(() => config.automaticUpdates),install: t.procedure.query(() => autoUpdater.quitAndInstall()),download: t.procedure.query(async () => {if (cancellationToken) return;- cancellationToken = new CancellationToken();- await autoUpdater- .downloadUpdate(cancellationToken)- .finally(() => (cancellationToken = undefined));+ clearTimeout(downloadTimeout);+ await new Promise<string[]>((resolve, reject) => {+ downloadTimeout = setTimeout(async () => {+ cancellationToken = new CancellationToken();+ autoUpdater.isUpdaterActive();+ await autoUpdater+ .downloadUpdate(cancellationToken)+ .then(resolve)+ .catch(reject)+ .finally(() => (cancellationToken = undefined));+ }, 1000);+ });}),check: t.procedure.query(async () => {- await autoUpdater.checkForUpdates().catch(console.error);+ if (cancellationToken) return;+ clearTimeout(downloadTimeout);+ await new Promise<void>((resolve) => {+ downloadTimeout = setTimeout(async () => {+ await autoUpdater+ .checkForUpdates()+ .catch(console.error)+ .finally(resolve);+ }, 1000);+ });}),toggleAutoUpdates: t.procedurediff --git a/apps/web/src/components/status-bar/index.tsx b/apps/web/src/components/status-bar/index.tsxindex ccf05ab1d..e354b29ec 100644--- a/apps/web/src/components/status-bar/index.tsx+++ b/apps/web/src/components/status-bar/index.tsx@@ -26,7 +26,6 @@ import {Update,SyncError,Alert,- Issue,SyncOff,Icon} from "../icons";@@ -40,7 +39,6 @@ import { checkForUpdate, installUpdate } from "../../utils/updater";import { getTimeAgo, toTitleCase } from "@notesnook/common";import { User } from "@notesnook/core";import { showUpdateAvailableNotice } from "../../dialogs/confirm";-import { IssueDialog } from "../../dialogs/issue-dialog";function StatusBar() {const user = useUserStore((state) => state.user);