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

Sync note after restoration to update the state #1774

Merged
merged 6 commits into from
Dec 18, 2019

Conversation

belcherj
Copy link
Contributor

Fix

Fixes #1772

After restoring a note the editor was stuck o the selected revision. This PR
clears that revision from the flux state. Additionally, that restoration of a
note was not causing a sync to occur. This triggers a note sync that updates
everything and cements the restored version as the current version.

Test

  1. Open a note with history
  2. Open revision panel
  3. Select a version
  4. Restore a version
  5. Refresh
  6. Is note set to revision?
  7. Redo steps above, without refresh
  8. Select another note
  9. Select note that you accepted revision on
  10. Is the note still on the revision?

Review

Only one developer is required to review these changes, but anyone can perform the review.

Release

RELEASE-NOTES.txt was updated with:

After restoring a note the editor was stuck o the selected revision. This PR
clears that revision from the flux state. Additionally, that restoration of a
note was not causing a sync to occur.  This triggers a note sync that updates
everything and cements the restored version as the current version.
@belcherj belcherj self-assigned this Dec 11, 2019
lib/app.jsx Outdated Show resolved Hide resolved
const { noteBucket } = this.props;

noteBucket.update(note.id, updatedNote.data, {}, { sync: false });
noteBucket.update(note.id, updatedNote.data, {}, { sync });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would think passing true here to sync would cause a sync but it doesn't.

Copy link
Member

Choose a reason for hiding this comment

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

What indicators are telling you that it isn't?

If it's not then we're probably seeing some other problem.

Also, since we can't get rid of syncNote() anyway where do you see the tradeoffs between adding the sync param here and calling syncNote() in the revision-selector?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What indicators are telling you that it isn't?

The note list isn't updating, if you refresh before adding more text to the note it resets back to before the revision was restored.

Also, since we can't get rid of syncNote() anyway where do you see the tradeoffs between adding the sync param here and calling syncNote() in the revision-selector?

I'm not really sure what you are asking.

Copy link
Member

Choose a reason for hiding this comment

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

The note list isn't updating, if you refresh before adding more text to the note it resets back to before the revision was restored.

This could go back to our funny data flow. Simperium operations really ought to be watching app operations and updating independently as side-effects, likewise should probably call some app action to update a note. It's not clear throughout who owns the data - Simperium, or our local copy in app state.

I'm not really sure what you are asking.

In this PR we're adding a new boolean parameter to onUpdateContent but another function already exists to do what we want: this.syncNote()

My question was why we choose to do that instead of call syncNote() when restoring a revision. I can make a guess that it's because we'd have to pass syncNote() down the component tree which would involve more work but I didn't know if you had another conclusion I didn't see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could go back to our funny data flow. Simperium operations really ought to be watching app operations and updating independently as side-effects, likewise should probably call some app action to update a note. It's not clear throughout who owns the data - Simperium, or our local copy in app state.

I don't think we can address this in this PR. I'd really like to get this in so the app isn't broken.

My question was why we choose to do that instead of call syncNote() when restoring a revision. I can make a guess that it's because we'd have to pass syncNote() down the component tree which would involve more work but I didn't know if you had another conclusion I didn't see.

  1. I didn't want to have to pass it down
  2. The whole pass it down thing is a pretty terrible practice in general
  3. The revision selector component shouldn't really have to worry about what to do when a revision is restored. I didn't want to add additional complexity down stream.

Copy link
Member

Choose a reason for hiding this comment

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

  1. I didn't want to have to pass it down
  2. The whole pass it down thing is a pretty terrible practice in general

I agree, though I've been staying in line with our practice of passing things down for the sake of consistency until we get a chance to do real refactoring in the app. I personally want to see these pass-downs all replaced with predictable and semantically-oriented Redux action calls so that we can get rid of the real culprit - complicated interplay with side-effects.

  1. The revision selector component shouldn't really have to worry about what to do when a revision is restored. I didn't want to add additional complexity down stream.

Given the way the app works I don't agree as much on this one. The tags, for example, immediately sync once we add them or remove them. The editor is the odd-ball maybe and perhaps it should hold the exception, but there's good reason in my mind to make an explicit "sync now" when replacing the editor text with a revision vs "sync soon" when editing text directly.

If it were me writing this PR I think that I'd pass down syncNote() and that's about a 65%-75% confidence. It's not me though and I have no strong objection here, meaning that I support your choices. Mainly I wanted to get on the same page and talk about it, because it stood out to me as a bit unexpected here (plus it's introducing a new boolean function argument which I like to avoid).

Don't think too much about it.

Copy link
Member

Choose a reason for hiding this comment

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

In <NoteDetail /> we see where we control syncNote() separate to enforce an update after checking a todo item. It's not inconsistent with this PR so it'd be good if we either updated the PR code to match the existing pattern in the codebase or updated the toggleTask() so match the new patterns introduced here.

@belcherj
Copy link
Contributor Author

Merging. We can revisit if need be.

@belcherj belcherj merged commit 5fcb385 into develop Dec 18, 2019
@belcherj belcherj deleted the fix/revision-restoration branch December 18, 2019 18:51
@codebykat codebykat added this to the 1.14 milestone Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

History: Restoring a note breaks the note list
3 participants