mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-08-31 02:58:34 +02:00
Compare commits
2 Commits
fix-loadin
...
fix/restor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f32ef8a49a | ||
|
|
606df2b851 |
@@ -40,7 +40,8 @@ function showItemDeletedToast(item) {
|
||||
toast.hide();
|
||||
let trashItem = db.trash.all.find((i) => i.id === item.id);
|
||||
if (!trashItem) return;
|
||||
await db.trash.restore(trashItem.id);
|
||||
const restored = await db.trash.restore(trashItem.id);
|
||||
if (restored === false) return;
|
||||
nbstore.refresh();
|
||||
notestore.refresh();
|
||||
};
|
||||
|
||||
@@ -83,7 +83,6 @@ const menuItems: (item: TrashItemType, ids?: string[]) => MenuItem[] = (
|
||||
icon: Restore.path,
|
||||
onClick: async () => {
|
||||
await store.restore(...ids);
|
||||
showToast("success", strings.action("item", ids.length, "restored"));
|
||||
},
|
||||
multiSelect: true
|
||||
},
|
||||
|
||||
@@ -24,6 +24,8 @@ import { store as appStore } from "./app-store";
|
||||
import { store as noteStore } from "./note-store";
|
||||
import { store as notebookStore } from "./notebook-store";
|
||||
import { TrashItem, VirtualizedGrouping } from "@notesnook/core";
|
||||
import { showToast } from "../utils/toast";
|
||||
import { strings } from "@notesnook/intl";
|
||||
|
||||
class TrashStore extends BaseStore<TrashStore> {
|
||||
trash: VirtualizedGrouping<TrashItem> | undefined = undefined;
|
||||
@@ -41,7 +43,9 @@ class TrashStore extends BaseStore<TrashStore> {
|
||||
};
|
||||
|
||||
restore = async (...ids: string[]) => {
|
||||
await db.trash.restore(...ids);
|
||||
const restored = await db.trash.restore(...ids);
|
||||
if (restored === false) return;
|
||||
showToast("success", strings.action("item", ids.length, "restored"));
|
||||
await this.get().refresh();
|
||||
await appStore.refreshNavItems();
|
||||
await noteStore.refresh();
|
||||
|
||||
@@ -25,7 +25,11 @@ import { SQLCollection } from "../database/sql-collection.js";
|
||||
import { isFalse } from "../database/index.js";
|
||||
import { sql } from "@streetwriters/kysely";
|
||||
import { deleteItems } from "../utils/array.js";
|
||||
import { CHECK_IDS, checkIsUserPremium } from "../common.js";
|
||||
import {
|
||||
CHECK_IDS,
|
||||
checkIsUserPremium,
|
||||
FREE_NOTEBOOKS_LIMIT
|
||||
} from "../common.js";
|
||||
|
||||
export class Notebooks implements ICollection {
|
||||
name = "notebooks";
|
||||
@@ -62,7 +66,7 @@ export class Notebooks implements ICollection {
|
||||
|
||||
if (
|
||||
!oldNotebook &&
|
||||
(await this.all.count()) >= 20 &&
|
||||
(await this.all.count()) >= FREE_NOTEBOOKS_LIMIT &&
|
||||
!(await checkIsUserPremium(CHECK_IDS.notebookAdd))
|
||||
)
|
||||
return;
|
||||
|
||||
@@ -29,6 +29,11 @@ import {
|
||||
} from "../utils/grouping.js";
|
||||
import { sql } from "@streetwriters/kysely";
|
||||
import { MAX_SQL_PARAMETERS } from "../database/sql-collection.js";
|
||||
import {
|
||||
CHECK_IDS,
|
||||
checkIsUserPremium,
|
||||
FREE_NOTEBOOKS_LIMIT
|
||||
} from "../common.js";
|
||||
|
||||
export default class Trash {
|
||||
collections = ["notes", "notebooks"] as const;
|
||||
@@ -192,6 +197,13 @@ export default class Trash {
|
||||
}
|
||||
|
||||
if (notebookIds.length > 0) {
|
||||
const notebooksLimitReached =
|
||||
(await this.db.notebooks.all.count()) + notebookIds.length >
|
||||
FREE_NOTEBOOKS_LIMIT;
|
||||
const isUserPremium = await checkIsUserPremium(CHECK_IDS.notebookAdd);
|
||||
if (notebooksLimitReached && !isUserPremium) {
|
||||
return false;
|
||||
}
|
||||
const ids = [...notebookIds, ...(await this.subNotebooks(notebookIds))];
|
||||
await this.db.notebooks.collection.update(ids, {
|
||||
type: "notebook",
|
||||
|
||||
@@ -142,3 +142,5 @@ export const DATE_FORMATS = [
|
||||
export const TIME_FORMATS = ["12-hour", "24-hour"];
|
||||
|
||||
export const CURRENT_DATABASE_VERSION = 6.1;
|
||||
|
||||
export const FREE_NOTEBOOKS_LIMIT = 20;
|
||||
|
||||
Reference in New Issue
Block a user