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
mobile: fix errors
Ammar Ahmedcb70bb942923
diff --git a/apps/mobile/app/screens/editor/index.tsx b/apps/mobile/app/screens/editor/index.tsxindex 9c711dd75..d5dfd99fe 100755--- a/apps/mobile/app/screens/editor/index.tsx+++ b/apps/mobile/app/screens/editor/index.tsx@@ -145,6 +145,7 @@ const Editor = React.memo(nestedScrollEnabledonError={onError}injectedJavaScriptBeforeContentLoaded={`+ globalThis.__DEV__ = ${__DEV__}globalThis.readonly=${readonly};globalThis.noToolbar=${noToolbar};globalThis.noHeader=${noHeader};diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.tsindex 3e5d0af12..9a1d88d73 100644--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts@@ -708,10 +708,7 @@ export const useEditor = (}if (locked && isEncryptedContent(data)) {- const decryptedContent = await db.vault?.decryptContent(- data,- noteId- );+ const decryptedContent = await db.vault?.decryptContent(data);if (!decryptedContent) {useTabStore.getState().updateTab(tabId, {locked: true,diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsxindex 03d6be0b8..239085216 100644--- a/packages/editor-mobile/src/components/editor.tsx+++ b/packages/editor-mobile/src/components/editor.tsx@@ -80,30 +80,34 @@ const Tiptap = ({tabRef.current = tab;function restoreNoteSelection(state?: NoteState) {- if (!tabRef.current.noteId) return;- const noteState =- state || useTabStore.getState().noteState[tabRef.current.noteId];-- if (noteState.to || noteState.from) {- const size = editors[tabRef.current.id]?.state.doc.content.size || 0;- if (- noteState.to > 0 &&- noteState.to <= size &&- noteState.from > 0 &&- noteState.from <= size- ) {- editors[tabRef.current.id]?.chain().setTextSelection({- to: noteState.to,- from: noteState.from- });+ try {+ if (!tabRef.current.noteId) return;+ const noteState =+ state || useTabStore.getState().noteState[tabRef.current.noteId];++ if (noteState && (noteState.to || noteState.from)) {+ const size = editors[tabRef.current.id]?.state.doc.content.size || 0;+ if (+ noteState.to > 0 &&+ noteState.to <= size &&+ noteState.from > 0 &&+ noteState.from <= size+ ) {+ editors[tabRef.current.id]?.chain().setTextSelection({+ to: noteState.to,+ from: noteState.from+ });+ }}- }- containerRef.current?.scrollTo({- left: 0,- top: noteState.top || 0,- behavior: "auto"- });+ containerRef.current?.scrollTo({+ left: 0,+ top: noteState?.top || 0,+ behavior: "auto"+ });+ } catch (e) {+ logger("error", (e as Error).message, (e as Error).stack);+ }}usePermissionHandler({@@ -210,31 +214,6 @@ const Tiptap = ({onCreate() {setTimeout(() => {restoreNoteSelection();- const noteState = tabRef.current.noteId- ? useTabStore.getState().noteState[tabRef.current.noteId]- : undefined;- const top = noteState?.top;- logger(- "info",- "editor.onCreate",- tabRef.current?.noteId,- noteState?.top,- noteState?.to,- noteState?.from- );-- if (noteState?.to || noteState?.from) {- editors[tabRef.current.id]?.chain().setTextSelection({- to: noteState.to,- from: noteState.from- });- }-- containerRef.current?.scrollTo({- left: 0,- top: top || 0,- behavior: "auto"- });}, 32);},downloadOptions: {diff --git a/packages/editor-mobile/src/utils/index.ts b/packages/editor-mobile/src/utils/index.tsindex 00b0135a2..b0f4f58fd 100644--- a/packages/editor-mobile/src/utils/index.ts+++ b/packages/editor-mobile/src/utils/index.ts@@ -135,6 +135,8 @@ declare global {| undefined>;+ var __DEV__: boolean;+function logger(type: "info" | "warn" | "error", ...logs: unknown[]): void;function dbLogger(type: "log" | "error", ...logs: unknown[]): void;/**@@ -229,6 +231,8 @@ export function logger(type: "info" | "warn" | "error",...logs: unknown[]): void {+ if (typeof globalThis.__DEV__ !== "undefined" && !globalThis.__DEV__) return;+const logString = logs.map((log) => {return typeof log !== "string" ? JSON.stringify(log) : log;