Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

note should reload in editor if needed on restoring note version from history

ammarahm-ed2f8d7fc2dc7c
diff --git a/apps/mobile/src/components/NoteHistory/index.js b/apps/mobile/src/components/NoteHistory/index.js
index a85552f18..42e493b57 100644
--- a/apps/mobile/src/components/NoteHistory/index.js
+++ b/apps/mobile/src/components/NoteHistory/index.js
@@ -28,7 +28,7 @@ export default function NoteHistory({note, ref}) {
}, []);
async function preview(item) {
- let content = await db.noteHistory.content(item.sessionContentId);
+ let content = await db.noteHistory.content(item.id);
presentSheet({
component: (
diff --git a/apps/mobile/src/components/NoteHistory/preview.js b/apps/mobile/src/components/NoteHistory/preview.js
index 03cd518a8..96254fb53 100644
--- a/apps/mobile/src/components/NoteHistory/preview.js
+++ b/apps/mobile/src/components/NoteHistory/preview.js
@@ -1,16 +1,15 @@
-import React, {useRef} from 'react';
-import {View} from 'react-native';
+import React, { useRef } from 'react';
+import { View } from 'react-native';
import WebView from 'react-native-webview';
-import {useTracked} from '../../provider';
-import {eSendEvent, ToastEvent} from '../../services/EventManager';
+import { useTracked } from '../../provider';
+import { useEditorStore } from '../../provider/stores';
+import { eSendEvent, ToastEvent } from '../../services/EventManager';
import Navigation from '../../services/Navigation';
-import {dHeight, itemSkus} from '../../utils';
-import {db} from '../../utils/database';
-import {eCloseProgressDialog} from '../../utils/Events';
-import {normalize} from '../../utils/SizeUtils';
-import {timeConverter} from '../../utils/TimeUtils';
-import {sourceUri} from '../../views/Editor/Functions';
-import {Button} from '../Button';
+import { db } from '../../utils/database';
+import { eCloseProgressDialog, eOnLoadNote } from '../../utils/Events';
+import { normalize } from '../../utils/SizeUtils';
+import { getNote, sourceUri } from '../../views/Editor/Functions';
+import { Button } from '../Button';
import DialogHeader from '../Dialog/dialog-header';
export default function NotePreview({session, content}) {
@@ -24,6 +23,7 @@ export default function NotePreview({session, content}) {
content,
'placeholder.svg'
);
+
console.log(preview, 'preview');
postMessage('htmldiff', preview?.data);
let theme = {...colors};
@@ -62,6 +62,11 @@ export default function NotePreview({session, content}) {
async function restore() {
await db.noteHistory.restore(session.id);
+ if (useEditorStore.getState()?.currentEditingNote === session?.noteId) {
+ if (getNote()) {
+ eSendEvent(eOnLoadNote, {...getNote(), forced: true});
+ }
+ }
eSendEvent(eCloseProgressDialog, 'note_history');
eSendEvent(eCloseProgressDialog);
Navigation.setRoutesToUpdate([
@@ -69,6 +74,7 @@ export default function NotePreview({session, content}) {
Navigation.routeNames.Favorites,
Navigation.routeNames.Notes
]);
+
ToastEvent.show({
heading: 'Note restored successfully',
type: 'success'
@@ -112,7 +118,12 @@ export default function NotePreview({session, content}) {
style={{
paddingHorizontal: 12
}}>
- <Button onPress={restore} title="Restore this version" type="accent" width="100%" />
+ <Button
+ onPress={restore}
+ title="Restore this version"
+ type="accent"
+ width="100%"
+ />
</View>
</View>
);
diff --git a/apps/mobile/src/views/Editor/EditorHeader.js b/apps/mobile/src/views/Editor/EditorHeader.js
index 11126dc5d..682f0c872 100644
--- a/apps/mobile/src/views/Editor/EditorHeader.js
+++ b/apps/mobile/src/views/Editor/EditorHeader.js
@@ -42,6 +42,7 @@ import {EditorTitle} from './EditorTitle';
import {
clearEditor,
clearTimer,
+ EditorWebView,
getNote,
loadNote,
setColors,
@@ -177,6 +178,7 @@ const EditorHeader = () => {
'Pin',
'Favorite',
'Publish',
+ 'History',
...android
]);
};
@@ -337,6 +339,8 @@ const EditorHeader = () => {
}}
top={50}
onPress={async () => {
+ EditorWebView.current?.reload();
+ return;
if (editing.isFocused) {
safeKeyboardDismiss();
editing.isFocused = true;