Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile: Fixes: #10677: Following a link to a previously open note wouldn't work #10750

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions packages/app-mobile/components/screens/Note.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -574,18 +574,10 @@ class NoteScreenComponent extends BaseScreenComponent<Props, State> implements B

this.props.dispatch({
type: 'NAV_GO',
routeName: 'Notes',
folderId: this.state.note.parent_id,
routeName: 'Note',
noteId: noteId,
noteHash: noteHash,
});

shim.setTimeout(() => {
this.props.dispatch({
type: 'NAV_GO',
routeName: 'Note',
noteId: noteId,
noteHash: noteHash,
});
}, 5);
}
}

Expand Down Expand Up @@ -1688,6 +1680,16 @@ class NoteScreenComponent extends BaseScreenComponent<Props, State> implements B
}
}

// We added this change to reset the component state when the props.noteId is changed.
// NoteScreenComponent original implementation assumed that noteId would never change,
// which can cause some bugs where previously set state to another note would interfere
// how the new note should be rendered
const NoteScreenWrapper = (props: Props) => {
return (
<NoteScreenComponent key={props.noteId} {...props} />
);
};

const NoteScreen = connect((state: AppState) => {
return {
noteId: state.selectedNoteIds.length ? state.selectedNoteIds[0] : null,
Expand All @@ -1711,6 +1713,6 @@ const NoteScreen = connect((state: AppState) => {
// confusing.
useEditorBeta: !state.settings['editor.usePlainText'],
};
})(NoteScreenComponent);
})(NoteScreenWrapper);

export default NoteScreen;
Loading