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: minor cleanup
thecodrrd59788ee00b2
diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.jsindex 8aff664b8..84cea7104 100644--- a/apps/web/src/common/index.js+++ b/apps/web/src/common/index.js@@ -49,34 +49,6 @@ export async function introduceFeatures() {export const DEFAULT_CONTEXT = { colors: [], tags: [], notebook: {} };-export function notesFromContext(context) {- let notes = [];- switch (context.type) {- case "tag":- notes = db.notes.tagged(context.value);- break;- case "color":- notes = db.notes.colored(context.value);- break;- case "topic":- const notebook = db.notebooks.notebook(context?.value?.id);- if (!notebook) break;- const topic = notebook.topics?.topic(context?.value?.topic);- if (!topic) break;- notes = topic.all;- break;- case "favorite":- notes = db.notes.favorites;- break;- case "monographs":- notes = db.monographs.all;- break;- default:- return [];- }- return notes;-}-export async function createBackup(save = true) {const encryptBackups = Config.get("encryptBackups", false);const data = await showLoadingDialog({diff --git a/apps/web/src/components/editor/context.ts b/apps/web/src/components/editor/context.tsindex 55e975670..4b3118a3f 100644--- a/apps/web/src/components/editor/context.ts+++ b/apps/web/src/components/editor/context.ts@@ -4,7 +4,7 @@ import createStore from "../../common/store";import BaseStore from "../../stores";import { UseStore } from "zustand";import shallow from "zustand/shallow";-import { ToolbarDefinition } from "@streetwriters/editor";+import type { ToolbarDefinition } from "@streetwriters/editor";type EditorSubState = {editor?: IEditor;diff --git a/apps/web/src/stores/note-store.js b/apps/web/src/stores/note-store.jsindex 0e3709edc..be087ef4e 100644--- a/apps/web/src/stores/note-store.js+++ b/apps/web/src/stores/note-store.js@@ -1,4 +1,3 @@-import { notesFromContext } from "../common";import { db } from "../common/db";import createStore from "../common/store";import { store as editorStore } from "./editor-store";@@ -180,3 +179,31 @@ class NoteStore extends BaseStore {*/const [useStore, store] = createStore(NoteStore);export { useStore, store };++function notesFromContext(context) {+ let notes = [];+ switch (context.type) {+ case "tag":+ notes = db.notes.tagged(context.value);+ break;+ case "color":+ notes = db.notes.colored(context.value);+ break;+ case "topic":+ const notebook = db.notebooks.notebook(context?.value?.id);+ if (!notebook) break;+ const topic = notebook.topics?.topic(context?.value?.topic);+ if (!topic) break;+ notes = topic.all;+ break;+ case "favorite":+ notes = db.notes.favorites;+ break;+ case "monographs":+ notes = db.monographs.all;+ break;+ default:+ return [];+ }+ return notes;+}diff --git a/apps/web/src/stores/user-store.js b/apps/web/src/stores/user-store.jsindex 19205f6d8..51933ea13 100644--- a/apps/web/src/stores/user-store.js+++ b/apps/web/src/stores/user-store.js@@ -1,6 +1,5 @@import createStore from "../common/store";import { db } from "../common/db";-import { store as appStore } from "./app-store";import BaseStore from "./index";import config from "../utils/config";import { EV, EVENTS } from "@streetwriters/notesnook-core/common";@@ -71,8 +70,7 @@ class UserStore extends BaseStore {state.isLoggedIn = false;});config.clear();- await appStore.refresh();-+ EV.publish(EVENTS.appRefreshRequested);if (!!reason) {await showAccountLoggedOutNotice(reason);}diff --git a/apps/web/src/utils/logger.ts b/apps/web/src/utils/logger.tsindex 0642bb328..cf611d571 100644--- a/apps/web/src/utils/logger.ts+++ b/apps/web/src/utils/logger.ts@@ -4,7 +4,6 @@ import {logManager,} from "@streetwriters/notesnook-core/logger";import FileSaver from "file-saver";-import { LogMessage } from "react-virtuoso/dist/loggerSystem";import { DatabasePersistence, NNStorage } from "../interfaces/storage";import { zip } from "./zip";@@ -19,9 +18,7 @@ async function downloadLogs() {const allLogs = await logManager.get();const files = allLogs.map((log) => ({filename: log.key,- content: (log.logs as LogMessage[])- .map((line) => JSON.stringify(line))- .join("\n"),+ content: (log.logs as any[]).map((line) => JSON.stringify(line)).join("\n"),}));const archive = await zip(files, "log");FileSaver.saveAs(new Blob([archive.buffer]), "notesnook-logs.zip");diff --git a/apps/web/src/views/auth.tsx b/apps/web/src/views/auth.tsxindex 058f821b8..2bf0272b3 100644--- a/apps/web/src/views/auth.tsx+++ b/apps/web/src/views/auth.tsx@@ -21,9 +21,9 @@ import Loader from "../components/loader";import { showToast } from "../utils/toast";import AuthContainer from "../components/auth-container";import { isTesting } from "../utils/platform";-import { AuthenticatorType } from "../components/dialogs/multi-factor-dialog";import { useTimer } from "../hooks/use-timer";import { ANALYTICS_EVENTS, trackEvent } from "../utils/analytics";+import { AuthenticatorType } from "../components/dialogs/mfa/types";type LoginFormData = {email: string;