web: add limit on notebook restoration

This commit is contained in:
Abdullah Atta
2025-07-14 13:46:59 +05:00
parent 872f4d7e91
commit 1a2a1da086
2 changed files with 10 additions and 2 deletions

View File

@@ -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",

View File

@@ -43,8 +43,7 @@ class TrashStore extends BaseStore<TrashStore> {
};
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();