Skip to content

Commit

Permalink
Refactor: Use direct comparison of note id when receiving remote upates
Browse files Browse the repository at this point in the history
In `onNoteBeforeRemoteUpdate` we give ourselves a chance to rebase local edits
on a note before remote changes are applied. Although we haven't identified any
problem related to this refactor, we have been using indirect measures to check
if the note we are working with is the note we think it is. That is, we were
checking against `selectedNoteId` as a proxy for `note.id` when relying on
`note.id` works and eliminates the possibility that `selectedNoteId` doesn't
match `note.id`

In this patch we're simplifying to rely solely on that direct measure and
eliminting one possible bug.
  • Loading branch information
dmsnell committed Jan 16, 2020
1 parent ee3c63e commit e5577de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/flux/app-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,10 @@ export const actionMap = new ActionMap({
creator({ noteId }: { noteId: T.EntityId }) {
return (dispatch, getState: () => State) => {
const {
appState: { selectedNoteId, note, notes },
appState: { note, notes },
} = getState();

if (selectedNoteId === noteId) {
if (note && note.id === noteId) {
return note.data;
}

Expand Down

0 comments on commit e5577de

Please sign in to comment.