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
web: show progress when rechecking attachments in bulk
Abdullah Atta1979cd2ea4bc
diff --git a/apps/web/src/stores/attachment-store.ts b/apps/web/src/stores/attachment-store.tsindex 3eb40947f..06e30075e 100644--- a/apps/web/src/stores/attachment-store.ts+++ b/apps/web/src/stores/attachment-store.ts@@ -28,6 +28,7 @@ import { AttachmentStream } from "../utils/streams/attachment-stream";import { createZipStream } from "../utils/streams/zip-stream";import { createWriteStream } from "../utils/stream-saver";import { Attachment } from "@notesnook/core";+import { TaskManager } from "../common/task-manager";let abortController: AbortController | undefined = undefined;class AttachmentStore extends BaseStore<AttachmentStore> {@@ -80,25 +81,36 @@ class AttachmentStore extends BaseStore<AttachmentStore> {};recheck = async (ids: string[]) => {- for (const id of ids) {- const attachment = await db.attachments.attachment(id);- if (!attachment) continue;- try {- this._changeWorkingStatus(attachment.hash, "recheck");-- const { failed, success } = await checkAttachment(attachment.hash);- this._changeWorkingStatus(- attachment.hash,- undefined,- success ? undefined : failed- );- } catch (e) {- console.error(e);- this._changeWorkingStatus(attachment.hash);- if (e instanceof Error)- showToast("error", `Rechecking failed: ${e.message}`);- }- }+ await TaskManager.startTask({+ type: "status",+ action: async (report) => {+ let i = 0;+ for (const id of ids) {+ report({+ text: `Checking attachments (${++i}/${ids.length})`+ });+ const attachment = await db.attachments.attachment(id);+ if (!attachment) continue;+ try {+ this._changeWorkingStatus(attachment.hash, "recheck");++ const { failed, success } = await checkAttachment(attachment.hash);+ this._changeWorkingStatus(+ attachment.hash,+ undefined,+ success ? undefined : failed+ );+ } catch (e) {+ console.error(e);+ this._changeWorkingStatus(attachment.hash);+ if (e instanceof Error)+ showToast("error", `Rechecking failed: ${e.message}`);+ }+ }+ },+ id: "checking-attachments",+ title: "Checking attachments"+ });};rename = async (hash: string, newName: string) => {