Skip to content

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

fix: db.notes.tagged return array with 1 undefined item

thecodrr21327d591891
diff --git a/packages/core/collections/notes.js b/packages/core/collections/notes.js
index ef5759041..4563ad07c 100644
--- a/packages/core/collections/notes.js
+++ b/packages/core/collections/notes.js
@@ -120,8 +120,10 @@ export default class Notes extends Collection {
return tfun.filter(".favorite === true")(this.all);
}
- tagged(tag) {
- return this._db.tags.notes(tag).map((id) => this._collection.getItem(id));
+ tagged(tagId) {
+ const tag = this._db.tags.tag(tagId);
+ if (!tag || tag.noteIds.length <= 0) return [];
+ return tag.noteIds.map((id) => this._collection.getItem(id));
}
colored(color) {
diff --git a/packages/core/collections/tags.js b/packages/core/collections/tags.js
index 4225bc379..729042db2 100644
--- a/packages/core/collections/tags.js
+++ b/packages/core/collections/tags.js
@@ -4,12 +4,6 @@ import { qclone } from "qclone";
import set from "../utils/set";
export default class Tags extends Collection {
- notes(tag) {
- const tagItem = this.all.find((t) => t.title === tag);
- if (!tagItem) return [];
- return tagItem.noteIds;
- }
-
tag(id) {
const tagItem = this.all.find((t) => t.id === id);
if (!tagItem) return;