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

Fix: Update selected note when making changes in the editor view #1880

Merged
merged 2 commits into from
Feb 6, 2020

Conversation

dmsnell
Copy link
Contributor

@dmsnell dmsnell commented Feb 4, 2020

Resolves #1878
Resolves #1879
Resolves #1882

It appears that we removed a flow in #1851 which updated app state in response
to updates from the note editor1. While this didn't impact the operation of
the editor it did present itself as a bug when previewing markdown-rendered
notes. The editor is stateful on its own and so continued to function
independently of the state of the selected note's content. The preview,
however, grabs the contents of the selected note whenever it's activated and
then renders those into a DOM node. This means that it showed the old contents
of the note unless you navigated to another note and back, which swapped out
the selected note with the new updated contents.

In this patch, which currently is probably wrong in some way, we're updating
the selected note when calling onChangeContent so that we don't get out of
sync with the data sources. Hopefully at the end of our state cleanup and
stabilization project this will disappear but for now this fix catches the
gap that left split data sources.

Probably there were other bugs we didn't discover as a result of this.

Mainly we need to test and audit for traces of cycles/loops in the update
so that we don't start spinning or overwriting data we just entered. In my
brief testing the easy cases worked as I expected them to simply and singly.

In develop
brokenPreview mov

In this branch
fixedPreview mov

Props to @surfer0627 for reporting

Resolves #1879

It appears that we removed a flow in #1851 which updated app state in response
to updates from the note editor[1]. While this didn't impact the operation of
the editor it did present itself as a bug when previewing markdown-rendered
notes. The editor is stateful on its own and so continued to function
independently of the state of the selected note's content. The preview,
however, grabs the contents of the selected note whenever it's activated and
then renders those into a DOM node. This means that it showed the old contents
of the note unless you navigated to another note and back, which swapped out
the selected note with the new updated contents.

In this patch, which currently is probably wrong in some way, we're updating
the selected note when calling `onChangeContent` so that we don't get out of
sync with the data sources. Hopefully at the end of our state cleanup and
stabilization project this will disappear but for now this fix catches the
gap that left split data sources.

Probably there were other bugs we didn't discover as a result of this.

Mainly we need to test and audit for traces of cycles/loops in the update
so that we don't start spinning or overwriting data we just entered. In my
brief testing the easy cases worked as I expected them to simply and singly.

[1]: https://github.com/Automattic/simplenote-electron/pull/1851/files#diff-3c87750a7cc32e0127447ffc78f5c0d5L300
@dmsnell dmsnell requested review from belcherj and a team February 4, 2020 18:44
Copy link
Contributor

@belcherj belcherj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not test but code looks good.

…e server

When tags were being updated in the pap they also came through this function
but they weren't coming through `onUpdateContent`, meaning that our fix
overlooked tags and probably also system tags and the like.

In this patch we're no longer selectively updating the note if it has a remote
patch (indicating that it came from another device). Instead, we're always
updating and selectively setting `hasRemoteUpdate` based on that knowledge.
This ensures that we maintain consistency with local updates.
@dmsnell
Copy link
Contributor Author

dmsnell commented Feb 5, 2020

Testing

  • Logout
  • Login with wrong password fails
  • Login with correct password
  • Create new note appears in other device
  • Changes to new note sync to other device
  • Changes to new note sync from other device (after debounce delay)
  • New tag immediately syncs to other device
  • New tag immediately syncs from other device
  • Removed tag immediately syncs to other device
  • Removed tag immediately syncs from other device
  • Note publishes with link
  • Note unpublishes
  • Note publish change syncs from other device (visible with dialog open)
  • Markdown setting syncs from other device
  • Preview mode disappears/reappears when receiving remote changes to markdown setting
  • Note pinning syncs immediately from either direction
  • Note pinning works regardless if clicking in list view or from note info
  • Viewing history on one device leaves note unchanged on other device
  • Restoring history immediately syncs note from both directions
  • Restoring history revisions updates pinned status (exists in develop) ⭕️
  • Restoring history revisions updates markdown status (exists in develop) ⭕️
  • Restoring history revisions updates publish status (exists in develop) ⭕️
  • Can view trashed notes by clicking on Trash
  • Can delete note forever from trash screen
  • Can restore note from trash screen
  • Can trash note
  • Can preview markdown with 👁 button
  • Can flip to edit mode with 👁 button
  • Markdown rendered in note list when markdown enabled
  • Markdown syntax unrendered in note list when markdown disabled
  • Can filter by tag when clicking on tag in tag drawer
  • Can search by keyword with tag selected
  • Searching in the search field highlights matches in note list
  • Searching in the search field highlights matches in the note editor
  • Searching in the search field highlights matches in the note editor during preview (exists in develop) ⭕️
  • Clearing the search field immediately updates filtered notes
  • Clicking on different tags or All Notes or Trash immediately updates filtered notes
  • Can search by keyword, filtering debounced
  • Tag auto-completes appear when typing in search field
  • Typing tag: does not result a list of all tags in the autocompleter
  • Typing tag: and something else, like tag:te results in autocomplete results starting with that something else, e.g. test
  • Search field updates with results of tag:test format search string
  • Can toggle sidebar
  • Syncs when introducing sequential surrogate pairs sharing the same high surrogate, e.g. 🅰🅱 to 🅰🅰🅱
  • When disabling network connectivity, changes start counting in unsync'ed changes counter
  • When going back online changes sync and counter resets to All chagnes synced
  • Can change analytics sharing setting
  • Changing Note Display mode immediately updates and reflects in note list
  • With sidebar disabled, toggling Line Length between Narrow and Full removes and adds border around note content appropriately and immediately.
  • Changing Sort Type mode immediately updates and reflects in note list
  • Toggling Sort Order immediately updates and reflects in note list for each sort type
  • For each sort type the pinned notes appear first in the note list
  • Changing Theme immediately updates app for desired color scheme
  • Using the Insert checklist item from the format menu inserts a checklist
  • "Undo" undoes the last edit
  • Typing - [x] creates a checked checklist item
  • Typing - [ ] created an unchecked checklist item
  • Typing - creates a list
  • Typing tab in a list item underneath another list item indents item
  • Typing shift tab in the same spot unindents the list
  • Changing - to + changes the list item bullet, also for * and (\u2022)
  • All list bullet types render to markdown lists center dot doesn't render as list (exists in develop) ⭕️
  • CmdOrCtrl + shift + p toggles preview mode
  • CmdOrCtrl + shift + (k or up) selects next note above current note, stops at top of list
  • CmdOrCtrl + shift + (j or down) selects next note below current note, stops at bottom of list
  • CmdOrCtrl + t toggles tab list (ctrl works but command doesn't) (exists in develop) ⭕️
  • CmdOrCtrl + n creates new note
  • CmdOrCtrl + shift + n when in small screen mode navigates to note list

@dmsnell
Copy link
Contributor Author

dmsnell commented Feb 6, 2020

Merging over failing tests since they are failing for other reasons; something in the AppVeyor config.

@dmsnell dmsnell closed this Feb 6, 2020
@dmsnell dmsnell reopened this Feb 6, 2020
@dmsnell dmsnell merged commit 9c14685 into develop Feb 6, 2020
@dmsnell dmsnell deleted the fix/1879-non-updated-notes branch February 6, 2020 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants