web: fix tags not showing in locked note (#7061)

Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
01zulfi
2024-12-10 09:58:13 +05:00
committed by GitHub
parent aa72c33aea
commit 1d78402d5d
5 changed files with 41 additions and 13 deletions

View File

@@ -197,6 +197,15 @@ test("update note", () =>
expect(note?.favorite).toBe(true);
}));
test("get note tags", () =>
noteTest({
...TEST_NOTE
}).then(async ({ db, id }) => {
const tag = await db.tags.add({ title: "hello" });
await db.relations.add({ type: "tag", id: tag }, { type: "note", id });
expect(await db.notes.tags(id)).toEqual([await db.tags.tag(tag)]);
}));
test("get favorite notes", () =>
noteTest({
...TEST_NOTE,

View File

@@ -176,6 +176,15 @@ export class Notes implements ICollection {
return note;
}
async tags(id: string) {
return this.db.relations
.to({ id, type: "note" }, "tag")
.selector.items(undefined, {
sortBy: "dateCreated",
sortDirection: "asc"
});
}
// note(idOrNote: string | Note) {
// if (!idOrNote) return;
// const note =