From 1a2a1da0866ea0ae4e4e6b3ac62c3f5085db8825 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 14 Jul 2025 13:46:59 +0500 Subject: [PATCH] web: add limit on notebook restoration --- apps/web/src/common/multi-select.ts | 9 +++++++++ apps/web/src/stores/trash-store.ts | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/web/src/common/multi-select.ts b/apps/web/src/common/multi-select.ts index 38d4deef7..f816aa34a 100644 --- a/apps/web/src/common/multi-select.ts +++ b/apps/web/src/common/multi-select.ts @@ -34,6 +34,8 @@ import { showMultiPermanentDeleteConfirmation } from "../dialogs/confirm"; import { strings } from "@notesnook/intl"; +import { isFeatureAvailable } from "@notesnook/common"; +import { showFeatureNotAllowedToast } from "./toasts"; async function moveNotesToTrash(ids: string[], confirm = true) { if (confirm && !(await showMultiDeleteConfirmation(ids.length))) return; @@ -183,6 +185,13 @@ async function deleteTags(ids: string[]) { async function restoreItemsFromTrash(ids: string[]) { if (!ids.length) return; + const notebookIds = ids.filter((id) => db.trash.cache.notebooks.includes(id)); + const result = await isFeatureAvailable( + "notebooks", + (await db.notebooks.all.count()) + notebookIds.length + ); + if (!result.isAllowed) return showFeatureNotAllowedToast(result); + await TaskManager.startTask({ type: "status", id: "restoreItems", diff --git a/apps/web/src/stores/trash-store.ts b/apps/web/src/stores/trash-store.ts index 22dcdaacd..1a805dc62 100644 --- a/apps/web/src/stores/trash-store.ts +++ b/apps/web/src/stores/trash-store.ts @@ -43,8 +43,7 @@ class TrashStore extends BaseStore { }; restore = async (...ids: string[]) => { - const restored = await db.trash.restore(...ids); - if (restored === false) return; + await db.trash.restore(...ids); showToast("success", strings.actions.restored.item(ids.length)); await this.get().refresh(); await appStore.refreshNavItems();