Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: allow free users to assign same 5 tags without limits

Abdullah Attab5ab8e5d3ec9
diff --git a/packages/core/collections/tags.js b/packages/core/collections/tags.js
index 826980e4d..65eb164b4 100644
--- a/packages/core/collections/tags.js
+++ b/packages/core/collections/tags.js
@@ -22,6 +22,7 @@ import { makeId } from "../utils/id";
import { deleteItems, hasItem } from "../utils/array";
import setManipulator from "../utils/set";
import { Mutex } from "async-mutex";
+import { checkIsUserPremium, CHECK_IDS } from "../common";
export default class Tags extends Collection {
constructor(db, name, cached) {
@@ -50,6 +51,13 @@ export default class Tags extends Collection {
if (tag && !noteIds.length)
throw new Error("A tag with this id already exists.");
+ if (
+ !tag &&
+ this.all.length >= 5 &&
+ !(await checkIsUserPremium(CHECK_IDS.noteTag))
+ )
+ return;
+
tag = tag || {
title: tagId
};
diff --git a/packages/core/models/note.js b/packages/core/models/note.js
index 4da999920..9169c7065 100644
--- a/packages/core/models/note.js
+++ b/packages/core/models/note.js
@@ -160,12 +160,6 @@ export default class Note {
}
async tag(tag) {
- if (
- this._db.tags.all.length >= 5 &&
- !(await checkIsUserPremium(CHECK_IDS.noteTag))
- )
- return;
-
let tagItem = await this._db.tags.add(tag, this._note.id);
if (addItem(this._note.tags, tagItem.title))
await this._db.notes.add(this._note);