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: add support for setting note history session title
Ammar Ahmed1e023500be29
diff --git a/apps/mobile/app/components/note-history/index.tsx b/apps/mobile/app/components/note-history/index.tsxindex a369975db..a39cd11b8 100644--- a/apps/mobile/app/components/note-history/index.tsx+++ b/apps/mobile/app/components/note-history/index.tsx@@ -47,7 +47,7 @@ const HistoryItem = ({}: {index: number;items?: VirtualizedGrouping<HistorySession>;- note?: Note;+ note: Note;}) => {const [item] = useDBItem(index, "noteHistory", items);const { colors } = useThemeColors();@@ -73,6 +73,7 @@ const HistoryItem = ({session: getDate(item.dateCreated, item.dateModified)}}content={content}+ note={note}/>),context: "note_history"@@ -135,7 +136,7 @@ export default function NoteHistory({const renderItem = useCallback(({ index }: { index: number }) => (- <HistoryItem index={index} items={history} />+ <HistoryItem index={index} items={history} note={note} />),[history]);diff --git a/apps/mobile/app/components/note-history/preview.jsx b/apps/mobile/app/components/note-history/preview.tsxsimilarity index 72%rename from apps/mobile/app/components/note-history/preview.jsxrename to apps/mobile/app/components/note-history/preview.tsxindex 65dc0ba0f..c61f972c3 100644--- a/apps/mobile/app/components/note-history/preview.jsx+++ b/apps/mobile/app/components/note-history/preview.tsx@@ -37,21 +37,43 @@ import Paragraph from "../ui/typography/paragraph";import { diff } from "diffblazer";import { strings } from "@notesnook/intl";import { DefaultAppStyles } from "../../utils/styles";+import {+ HistorySession,+ isEncryptedContent,+ Note,+ NoteContent,+ SessionContentItem,+ TrashOrItem+} from "@notesnook/core";/**** @param {any} param0* @returns*/-export default function NotePreview({ session, content, note }) {+export default function NotePreview({+ session,+ content,+ note+}: {+ session: HistorySession & { session: string };+ content:+ | Partial<+ NoteContent<boolean> & {+ title: string;+ }+ >+ | undefined;+ note: TrashOrItem<Note>;+}) {const { colors } = useThemeColors();const [locked, setLocked] = useState(false);async function restore() {if (note && note.type === "trash") {- if ((await db.trash.restore(note.id)) === false) return;+ await db.trash.restore(note.id);Navigation.queueRoutesForUpdate();- useSelectionStore.getState().setSelectionMode(false);+ useSelectionStore.getState().setSelectionMode();ToastManager.show({heading: strings.noteRestored(),type: "success"@@ -91,15 +113,17 @@ export default function NotePreview({ session, content, note }) {negativeText: strings.cancel(),context: "local",positivePress: async () => {- await db.trash.delete(note.id);- useTrashStore.getState().refresh();- useSelectionStore.getState().setSelectionMode(false);- ToastManager.show({- heading: strings.noteDeleted(),- type: "success",- context: "local"- });- eSendEvent(eCloseSheet);+ if (note) {+ await db.trash.delete(note.id);+ useTrashStore.getState().refresh();+ useSelectionStore.getState().setSelectionMode();+ ToastManager.show({+ heading: strings.noteDeleted(),+ type: "success",+ context: "local"+ });+ eSendEvent(eCloseSheet);+ }},positiveType: "error"});@@ -113,8 +137,11 @@ export default function NotePreview({ session, content, note }) {}}><Dialog context="local" />- <DialogHeader padding={12} title={note?.title || session?.session} />- {!session?.locked && !locked ? (+ <DialogHeader+ padding={12}+ title={content?.title || note.title || session?.session}+ />+ {!session?.locked && !locked && content?.data ? (<Viewstyle={{flex: 1,@@ -125,17 +152,27 @@ export default function NotePreview({ session, content, note }) {editorId="historyPreview"onLoad={async (loadContent) => {try {- if (content.data) {- const _note = note || (await db.notes.note(session?.noteId));- const currentContent = await db.content.get(_note.contentId);- loadContent({- data: diff(currentContent.data, content.data),- id: _note.id- });+ if (content?.data) {+ const currentContent = note?.contentId+ ? await db.content.get(note.contentId)+ : undefined;++ if (+ currentContent?.data &&+ !isEncryptedContent(currentContent)+ ) {+ loadContent({+ data: diff(+ currentContent?.data || "<p></p>",+ content.data as string+ ),+ id: session?.noteId+ });+ }}} catch (e) {ToastManager.error(- e,+ e as Error,"Failed to load history preview","local");@@ -153,7 +190,9 @@ export default function NotePreview({ session, content, note }) {}}><Paragraph color={colors.secondary.paragraph}>- {strings.encryptedNoteHistoryNotice()}+ {!content?.data+ ? strings.noContent()+ : strings.encryptedNoteHistoryNotice()}</Paragraph></View>)}diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.tsindex 478b7dfeb..a2123fbfa 100644--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts@@ -298,7 +298,8 @@ export const useEditor = (return;}- if (isContentInvalid(data) && id) {+ if (!title && isContentInvalid(data) && id) {+ console.log("new editor session", title, isContentInvalid(data), id);// Create a new history session if recieved empty or invalid content// To ensure that history is preserved for correct content.currentSessionHistoryId = editorSessionHistory.newSession(id);@@ -312,6 +313,8 @@ export const useEditor = (sessionId: `${currentSessionHistoryId}`};+ console.log(noteData.sessionId);+noteData.title = title;if (ignoreEdit) {