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

Editor: Debounce autosave on last edit #10103

Merged
merged 2 commits into from Nov 2, 2018

Conversation

Projects
None yet
3 participants
@aduth
Member

aduth commented Sep 21, 2018

This pull request seeks to change the behavior of autosave such that an auto save does not occur until after the delay from the last edit made. Thus, so long as a user continues typing, an autosave will never occur until they are finished typing.

Testing instructions:

Verify that upon making a change to e.g. the title or content, an autosave occurs after 10 seconds of no action. Verify the implications of this specific behavior in that repeatedly making changes before the 10 seconds interval will reset the timer.

@tecnogaming

This comment has been minimized.

tecnogaming commented Sep 25, 2018

We need to have more control on the autosave feature. You need to understand that for tiny blogs there is no problem with the current implementation of autosave but for big blogs with up to 9 editors/writers all working at the same time, the autosave and the amount it does is overkill.

We DONT NEED that much autosave, we need to limit or disable it and there is no option. Gutenberg should not decide for itself, this needs to be added as an option to the user.

@aduth aduth force-pushed the add/with-last-change branch from 33e42af to d890ed2 Oct 31, 2018

@aduth aduth force-pushed the add/with-last-change branch from d890ed2 to 866e426 Oct 31, 2018

@aduth aduth requested a review from WordPress/gutenberg-core Oct 31, 2018

@aduth

This comment has been minimized.

Member

aduth commented Oct 31, 2018

I forgot I'd left this in a half-finished state. This should now be ready for review.

Since the initial commit, I've revised the approach to avoid relying on a non-deterministic value being introduced to the reducer state, instead taking an approach not too much unlike what we have with getBlockDependantsCacheBust. It's maybe an abuse of value comparisons in JavaScript, but it works reasonably well and avoids (a) a performance cost associated with populating the full edits / blocks into AutosaveMonitor and (b) otherwise exposing internal state structure of the store.

@aduth

This comment has been minimized.

Member

aduth commented Oct 31, 2018

@tecnogaming This pull request will help limit the number of autosaves which occur. Any further consideration should be discussed in a separate issue.

@aduth aduth force-pushed the add/with-last-change branch from 866e426 to c08ac65 Oct 31, 2018

* @return {*} A value whose reference will change only when an edit occurs.
*/
export const getReferenceByDistinctEdits = createSelector(
() => [],

This comment has been minimized.

@youknowriad

youknowriad Nov 1, 2018

Contributor

Nice trick :)

This PR assumes we track isDirty by the presence of edits, right? Can it create false positives if it's not the case?

@youknowriad

Works great in my testing

@youknowriad youknowriad added this to the 4.3 milestone Nov 1, 2018

@aduth aduth merged commit 5d5c4ff into master Nov 2, 2018

2 checks passed

codecov/project 48.59% (+0.01%) compared to 29f209a
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@aduth aduth deleted the add/with-last-change branch Nov 2, 2018

grey-rsi pushed a commit to OnTheGoSystems/gutenberg that referenced this pull request Nov 22, 2018

Editor: Debounce autosave on last edit (WordPress#10103)
* Editor: Debounce autosave on last edit

* Editor: Track last edits by reference change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment