Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
fix: switching notes from plain to different editors
Browse files Browse the repository at this point in the history
  • Loading branch information
radko93 committed Nov 26, 2020
1 parent 8464086 commit 47fb6b6
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/screens/Compose/Compose.tsx
Expand Up @@ -164,13 +164,7 @@ export const Compose = React.memo(

useEffect(() => {
let mounted = true;
if (
mounted &&
editor &&
editor.isTemplateNote &&
editor.note?.prefersPlainEditor &&
Platform.OS === 'ios'
) {
if (mounted && editor && editor.isTemplateNote && Platform.OS === 'ios') {
editorViewRef.current?.focus();
}
return () => {
Expand Down Expand Up @@ -324,9 +318,17 @@ export const Compose = React.memo(
setTitle(newNote.title);
setNoteText(newNote.text);
}

/**
* If the note change was triggered by a local change
* we only save it to local state if a meaningful value changed
* to avoid unecessary UI renders.
*/
if (
note?.prefersPlainEditor !== newNote.prefersPlainEditor ||
newNote.locked !== note?.locked
newNote.locked !== note?.locked ||
newNote.text !== note.text ||
newNote.title !== note.title
) {
if (note) {
setNote(newNote);
Expand Down

0 comments on commit 47fb6b6

Please sign in to comment.