Skip to content

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

core: do not check premium status during tag addition

Abdullah Atta0d2001307170
diff --git a/packages/core/collections/tags.js b/packages/core/collections/tags.js
index 65eb164b4..826980e4d 100644
--- a/packages/core/collections/tags.js
+++ b/packages/core/collections/tags.js
@@ -22,7 +22,6 @@ 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) {
@@ -51,13 +50,6 @@ 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 9169c7065..b04ad8185 100644
--- a/packages/core/models/note.js
+++ b/packages/core/models/note.js
@@ -160,6 +160,13 @@ export default class Note {
}
async tag(tag) {
+ if (
+ !this._db.tags.tag(tag) &&
+ 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);