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
refactor: use a single CHECK_IDS
thecodrr8daf56461694
diff --git a/packages/core/api/vault.js b/packages/core/api/vault.jsindex 780665d2c..1433d5ab3 100644--- a/packages/core/api/vault.js+++ b/packages/core/api/vault.js@@ -1,4 +1,4 @@-import { EV, sendCheckUserStatusEvent } from "../common";+import { CHECK_IDS, EV, sendCheckUserStatusEvent } from "../common";import getId from "../utils/id";const ERASE_TIME = 1000 * 60 * 30;@@ -89,7 +89,7 @@ export default class Vault {* @param {string} noteId The id of the note to lock*/async add(noteId) {- if (!(await sendCheckUserStatusEvent("vault:check"))) return;+ if (!(await sendCheckUserStatusEvent(CHECK_IDS.vaultAdd))) return;await this._check();await this._lockNote({ id: noteId });diff --git a/packages/core/collections/notebooks.js b/packages/core/collections/notebooks.jsindex 5aa7f74b5..cd09c462b 100644--- a/packages/core/collections/notebooks.js+++ b/packages/core/collections/notebooks.js@@ -3,7 +3,7 @@ import fuzzysearch from "fuzzysearch";import Notebook from "../models/notebook";import sort from "fast-sort";import getId from "../utils/id";-import { sendCheckUserStatusEvent } from "../common";+import { CHECK_IDS, sendCheckUserStatusEvent } from "../common";var tfun = require("transfun/transfun.js").tfun;if (!tfun) {tfun = global.tfun;@@ -24,7 +24,7 @@ export default class Notebooks extends Collection {if (!oldNotebook &&this.all.length >= 3 &&- !(await sendCheckUserStatusEvent("notebook:add"))+ !(await sendCheckUserStatusEvent(CHECK_IDS.notebookAdd)))return;diff --git a/packages/core/common.js b/packages/core/common.jsindex a8f82df62..888171834 100644--- a/packages/core/common.js+++ b/packages/core/common.js@@ -7,3 +7,12 @@ export async function sendCheckUserStatusEvent(type) {if (typeof results === "boolean") return results;return results.some((r) => r.type === type && r.result === true);}++export const CHECK_IDS = {+ noteColor: "note:color",+ noteTag: "note:tag",+ noteExport: "note:export",+ vaultAdd: "vault:add",+ notebookAdd: "notebook:add",+ backupEncrypt: "backup:encrypt",+};diff --git a/packages/core/models/note.js b/packages/core/models/note.jsindex 89a582e98..151f1fe81 100644--- a/packages/core/models/note.js+++ b/packages/core/models/note.js@@ -2,7 +2,7 @@ import MarkdownBuilder from "../utils/templates/markdown/builder";import HTMLBuilder from "../utils/templates/html/builder";import TextBuilder from "../utils/templates/text/builder";import { getContentFromData } from "../content-types";-import { EV, sendCheckUserStatusEvent } from "../common";+import { CHECK_IDS, sendCheckUserStatusEvent } from "../common";export default class Note {/**@@ -61,7 +61,7 @@ export default class Note {const { data, type } = await this._db.content.raw(this._note.contentId);let content = getContentFromData(type, data);- if (to !== "txt" && !(await sendCheckUserStatusEvent("note:export")))+ if (to !== "txt" && !(await sendCheckUserStatusEvent(CHECK_IDS.noteExport)))return;switch (to) {@@ -84,7 +84,7 @@ export default class Note {}async color(color) {- if (!(await sendCheckUserStatusEvent("note:colors"))) return;+ if (!(await sendCheckUserStatusEvent(CHECK_IDS.noteColor))) return;return await addTag.call(this, color, "colors");}@@ -95,7 +95,7 @@ export default class Note {async tag(tag) {if (this._db.tags.all.length >= 5 &&- !(await sendCheckUserStatusEvent("note:tags"))+ !(await sendCheckUserStatusEvent(CHECK_IDS.noteTag)))return;return await addTag.call(this, tag, "tags");