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: use migrations to dedup shortcuts
Abdullah Attacf8ed911023d
diff --git a/packages/core/collections/shortcuts.js b/packages/core/collections/shortcuts.jsindex 81212bbeb..4bf581031 100644--- a/packages/core/collections/shortcuts.js+++ b/packages/core/collections/shortcuts.js@@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import Collection from "./collection";-import { EV, EVENTS } from "../common";/*** @typedef {{@@ -45,11 +44,6 @@ export default class Shortcuts extends Collection {await this._collection.addItem(shortcut);}- async init() {- await super.init();- await this.dedupe();- }-/**** @param {Partial<Shortcut>} shortcut@@ -156,20 +150,4 @@ export default class Shortcuts extends Collection {await this._collection.removeItem(id);}}-- async dedupe() {- const oldShortcuts = this.all.filter(- (shortcut) => shortcut.id !== shortcut.item.id- );-- for (const shortcut of oldShortcuts) {- await this._collection.addItem({ ...shortcut, id: shortcut.item.id });- }-- for (const shortcut of oldShortcuts) {- await this._collection.removeItem(shortcut.id);- }-- if (oldShortcuts.length > 0) EV.publish(EVENTS.appRefreshRequested);- }}diff --git a/packages/core/migrations.js b/packages/core/migrations.jsindex 6ce471891..26cf858d7 100644--- a/packages/core/migrations.js+++ b/packages/core/migrations.js@@ -110,7 +110,12 @@ const migrations = [if (!item.data || item.data.iv) return item;item.type = "tiptap";return item;- },+ },+ shortcut: (item) => {+ if (item.id === item.item.id) return item;+ item.id = item.item.id;+ return item;+ },tiptap: (item) => {return changeSessionContentType(item);},