A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
core: shorcuts -> shortcuts
Abdullah Attaac7aad93b3c4
diff --git a/packages/core/__tests__/shortcuts.test.js b/packages/core/__tests__/shortcuts.test.jsindex 248028705..0db736b0b 100644--- a/packages/core/__tests__/shortcuts.test.js+++ b/packages/core/__tests__/shortcuts.test.js@@ -26,56 +26,56 @@ beforeEach(() => {test("create a shortcut of an invalid item should throw", () =>databaseTest().then(async (db) => {await expect(() =>- db.shorcuts.add({ item: { type: "HELLO!" } })+ db.shortcuts.add({ item: { type: "HELLO!" } })).rejects.toThrow(/cannot create a shortcut/i);}));test("create a shortcut of notebook", () =>notebookTest().then(async ({ db, id }) => {- await db.shorcuts.add({ item: { type: "notebook", id } });- expect(db.shorcuts.exists(id)).toBe(true);- expect(db.shorcuts.all[0].item.id).toBe(id);+ await db.shortcuts.add({ item: { type: "notebook", id } });+ expect(db.shortcuts.exists(id)).toBe(true);+ expect(db.shortcuts.all[0].item.id).toBe(id);}));test("create a duplicate shortcut of notebook", () =>notebookTest().then(async ({ db, id }) => {- await db.shorcuts.add({ item: { type: "notebook", id } });- await db.shorcuts.add({ item: { type: "notebook", id } });+ await db.shortcuts.add({ item: { type: "notebook", id } });+ await db.shortcuts.add({ item: { type: "notebook", id } });- expect(db.shorcuts.all).toHaveLength(1);- expect(db.shorcuts.all[0].item.id).toBe(id);+ expect(db.shortcuts.all).toHaveLength(1);+ expect(db.shortcuts.all[0].item.id).toBe(id);}));test("create shortcut of a topic", () =>notebookTest().then(async ({ db, id }) => {const notebook = db.notebooks.notebook(id)._notebook;const topic = notebook.topics[0];- await db.shorcuts.add({+ await db.shortcuts.add({item: { type: "topic", id: topic.id, notebookId: id }});- expect(db.shorcuts.all).toHaveLength(1);- expect(db.shorcuts.all[0].item.id).toBe(topic.id);+ expect(db.shortcuts.all).toHaveLength(1);+ expect(db.shortcuts.all[0].item.id).toBe(topic.id);}));test("pin a tag", () =>databaseTest().then(async (db) => {const tag = await db.tags.add("HELLO!");- await db.shorcuts.add({ item: { type: "tag", id: tag.id } });+ await db.shortcuts.add({ item: { type: "tag", id: tag.id } });- expect(db.shorcuts.all).toHaveLength(1);- expect(db.shorcuts.all[0].item.id).toBe(tag.id);+ expect(db.shortcuts.all).toHaveLength(1);+ expect(db.shortcuts.all[0].item.id).toBe(tag.id);}));test("remove shortcut", () =>databaseTest().then(async (db) => {const tag = await db.tags.add("HELLO!");- const shortcutId = await db.shorcuts.add({+ const shortcutId = await db.shortcuts.add({item: { type: "tag", id: tag.id }});- expect(db.shorcuts.all).toHaveLength(1);+ expect(db.shortcuts.all).toHaveLength(1);- await db.shorcuts.remove(shortcutId);- expect(db.shorcuts.all).toHaveLength(0);+ await db.shortcuts.remove(shortcutId);+ expect(db.shortcuts.all).toHaveLength(0);}));diff --git a/packages/core/api/index.js b/packages/core/api/index.jsindex 9968a4fbe..cdeb75c8f 100644--- a/packages/core/api/index.js+++ b/packages/core/api/index.js@@ -141,7 +141,7 @@ class Database {/**@type {NoteHistory} */this.noteHistory = await NoteHistory.new(this, "notehistory", false);/**@type {Shortcuts} */- this.shorcuts = await Shortcuts.new(this, "shorcuts");+ this.shortcuts = await Shortcuts.new(this, "shortcuts");this.trash = new Trash(this);diff --git a/packages/core/api/migrations.js b/packages/core/api/migrations.jsindex be2376f8f..090b2acbf 100644--- a/packages/core/api/migrations.js+++ b/packages/core/api/migrations.js@@ -76,8 +76,8 @@ class Migrations {type: "settings"},{- index: this._db.shorcuts.raw,- dbCollection: this._db.shorcuts+ index: this._db.shortcuts.raw,+ dbCollection: this._db.shortcuts},{index: this._db.notes.raw,diff --git a/packages/core/api/sync/collector.js b/packages/core/api/sync/collector.jsindex e4900d85e..a3a8f180a 100644--- a/packages/core/api/sync/collector.js+++ b/packages/core/api/sync/collector.js@@ -38,7 +38,7 @@ class Collector {const items = [...this._collect("note", this._db.notes.raw, isForceSync),- ...this._collect("shortcut", this._db.shorcuts.raw, isForceSync),+ ...this._collect("shortcut", this._db.shortcuts.raw, isForceSync),...this._collect("notebook", this._db.notebooks.raw, isForceSync),...this._collect("content", await this._db.content.all(), isForceSync),...this._collect(diff --git a/packages/core/api/sync/merger.js b/packages/core/api/sync/merger.jsindex 3c2d22632..e5e305f5f 100644--- a/packages/core/api/sync/merger.js+++ b/packages/core/api/sync/merger.js@@ -44,8 +44,8 @@ class Merger {set: (item) => this._db.notes.merge(item)},shortcut: {- get: (id) => this._db.shorcuts.shortcut(id),- set: (item) => this._db.shorcuts.merge(item)+ get: (id) => this._db.shortcuts.shortcut(id),+ set: (item) => this._db.shortcuts.merge(item)},notebook: {threshold: 1000,diff --git a/packages/core/collections/notebooks.js b/packages/core/collections/notebooks.jsindex c237f0b5d..1e00465c9 100644--- a/packages/core/collections/notebooks.js+++ b/packages/core/collections/notebooks.js@@ -165,7 +165,7 @@ export default class Notebooks extends Collection {const notebookData = qclone(notebook.data);await notebook.topics.delete(...notebook.data.topics);await this._collection.removeItem(id);- await this._db.settings.unpin(id);+ await this._db.shortcuts.remove(id);await this._db.trash.add(notebookData);}}diff --git a/packages/core/collections/tags.js b/packages/core/collections/tags.jsindex 605bbd48d..826980e4d 100644--- a/packages/core/collections/tags.js+++ b/packages/core/collections/tags.js@@ -120,7 +120,7 @@ export default class Tags extends Collection {if (hasItem(note.tags, tag.title)) await note.untag(tag.title);}- await this._db.settings.unpin(tagId);+ await this._db.shortcuts.remove(tagId);await this._collection.deleteItem(tagId);}@@ -135,7 +135,7 @@ export default class Tags extends Collection {if (tag.noteIds.length > 0) await this._collection.addItem(tag);else {- await this._db.settings.unpin(tag.id);+ await this._db.shortcuts.remove(tag.id);await this._collection.deleteItem(tag.id);}}diff --git a/packages/core/collections/topics.js b/packages/core/collections/topics.jsindex 263ecdb1f..2fd372c32 100644--- a/packages/core/collections/topics.js+++ b/packages/core/collections/topics.js@@ -117,7 +117,7 @@ export default class Topics {if (!topic) continue;await topic.delete(...topic._topic.notes);- await this._db.settings.unpin(topicId);+ await this._db.shortcuts.remove(topicId);const topicIndex = allTopics.findIndex((t) => t.id === topicId || t.title === topicIddiff --git a/packages/core/database/backup.js b/packages/core/database/backup.jsindex d310d8f5b..cb4cde1a6 100644--- a/packages/core/database/backup.js+++ b/packages/core/database/backup.js@@ -171,7 +171,7 @@ export default class Backup {},{index: data["shortcuts"],- dbCollection: this._db.shorcuts+ dbCollection: this._db.shortcuts},{index: data["notes"],