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

Show autosave message when autosave exists #4218

Merged
merged 29 commits into from
Jun 4, 2018
Merged
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
cc1a856
Rework PR 4218
Apr 13, 2018
c6d5cce
Merge branch 'master' of github.com:WordPress/gutenberg
Apr 18, 2018
3baae76
Merge branch 'master' into feature/heartbeat-autosaving
Apr 18, 2018
3444476
switch to withDispatch approach
Apr 18, 2018
ebe5dd4
fixes for eslint
Apr 18, 2018
045fd0f
remove unneeded braces
Apr 19, 2018
c97b109
REQUEST_AUTOSAVE_NOTICE: bail early if autosaveStatus is falsey
Apr 19, 2018
fb0988e
remove unused autosave reducer
Apr 19, 2018
68f0754
whitespace
Apr 19, 2018
4f2832c
Merge branch 'master' into feature/heartbeat-autosaving
Apr 20, 2018
9194bb7
remove field change check when retrieving autosave newer than post
Apr 20, 2018
5f816d1
cleanup, doc blcoks
Apr 20, 2018
95cb823
exit early if autosave false
Apr 20, 2018
80768f1
Merge branch 'master' into feature/heartbeat-autosaving
Apr 27, 2018
f625239
add missing simicolon
Apr 27, 2018
3e5e744
Merge branch 'master' of github.com:WordPress/gutenberg
May 23, 2018
9e97fed
Merge branch 'master' into feature/heartbeat-autosaving
May 23, 2018
cf9dd40
Merge branch 'master' of github.com:WordPress/gutenberg
May 29, 2018
f1991ad
Merge branch 'master' of github.com:WordPress/gutenberg
May 31, 2018
fb512ce
Merge branch 'master' of github.com:WordPress/gutenberg
May 31, 2018
171c511
Merge branch 'master' of github.com:WordPress/gutenberg
Jun 1, 2018
bdab38b
Merge branch 'master' into feature/heartbeat-autosaving
Jun 1, 2018
6323b25
spacing cleanup
Jun 1, 2018
fcd3d61
fix for eslint
Jun 1, 2018
5ceca78
Remove useless spans
youknowriad Jun 4, 2018
216dd49
Merge remote-tracking branch 'origin/master' into feature/heartbeat-a…
youknowriad Jun 4, 2018
52c75a5
Drop the showAutoSaveMessage action
youknowriad Jun 4, 2018
2054d34
Fix unit tests after removing the span
youknowriad Jun 4, 2018
0c0f8d3
Rename autosaveStatus property just "autosave"
youknowriad Jun 4, 2018
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
30 changes: 27 additions & 3 deletions editor/store/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,34 @@ export default {
optimist: { type: BEGIN, id: POST_UPDATE_TRANSACTION_ID },
isAutosave,
} );

let request;
if ( isAutosave ) {
toSend.parent = post.id;

request = wp.apiRequest( {
path: `/wp/v2/${ basePath }/${ post.id }/autosaves`,
method: 'POST',
data: toSend,
} );
} else {
dispatch( {
type: 'UPDATE_POST',
edits: toSend,
optimist: { id: POST_UPDATE_TRANSACTION_ID },
} );

dispatch( removeNotice( SAVE_POST_NOTICE_ID ) );
dispatch( removeNotice( AUTOSAVE_POST_NOTICE_ID ) );
const basePath = wp.api.getPostTypeRoute( getCurrentPostType( state ) );
wp.apiRequest( { path: `/wp/v2/${ basePath }/${ post.id }`, method: 'PUT', data: toSend } ).then(
dispatch( removeNotice( AUTOSAVE_POST_NOTICE_ID ) );

request = wp.apiRequest( {
path: `/wp/v2/${ basePath }/${ post.id }`,
method: 'PUT',
data: toSend,
} );
}

request.then(
( newPost ) => {
const reset = isAutosave ? resetAutosave : resetPost;
dispatch( reset( newPost ) );
Expand Down