mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
web: add limit on notebook restoration
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user