mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Improved save-waiting when leaving beta editor (#17929)
no issue - adds explicit waits for the two save tasks when leaving the editor before any other checks or saves are triggered - cleans up some errors around task cancellation that could be triggered when leaving the editor with an existing save running
This commit is contained in:
parent
2f5a4d801b
commit
127cbfa62d
@ -931,14 +931,20 @@ export default class LexicalEditorController extends Controller {
|
||||
return;
|
||||
}
|
||||
|
||||
// clean up blank cards when leaving the editor if we have a draft post
|
||||
// - blank cards could be left around due to autosave triggering whilst
|
||||
// a blank card is present then the user attempting to leave
|
||||
// - will mark the post as dirty so it gets saved when transitioning
|
||||
// TODO: not yet implemented in react editor
|
||||
// if (this._koenig && post.isDraft) {
|
||||
// this._koenig.cleanup();
|
||||
// }
|
||||
// wait for any save to finish before continuing to avoid any issues
|
||||
// with attempting a new save whilst another has requests in-flight
|
||||
if (this.saveTask.isRunning) {
|
||||
transition.abort();
|
||||
await this.saveTask.last;
|
||||
return transition.retry();
|
||||
}
|
||||
// extra handling for PSM-triggered save tasks that aren't captured above
|
||||
// NOTE: we don't wait on `_savePostTask` as it's only used as a child task
|
||||
if (this.savePostTask.isRunning) {
|
||||
transition.abort();
|
||||
await this.savePostTask.last;
|
||||
return transition.retry();
|
||||
}
|
||||
|
||||
// user can enter the slug name and then leave the post page,
|
||||
// in such case we should wait until the slug would be saved on backend
|
||||
@ -948,6 +954,15 @@ export default class LexicalEditorController extends Controller {
|
||||
return transition.retry();
|
||||
}
|
||||
|
||||
// clean up blank cards when leaving the editor if we have a draft post
|
||||
// - blank cards could be left around due to autosave triggering whilst
|
||||
// a blank card is present then the user attempting to leave
|
||||
// - will mark the post as dirty so it gets saved when transitioning
|
||||
// TODO: not yet implemented in lexical editor
|
||||
// if (this._koenig && post.isDraft) {
|
||||
// this._koenig.cleanup();
|
||||
// }
|
||||
|
||||
let hasDirtyAttributes = this.hasDirtyAttributes;
|
||||
let state = post.getProperties('isDeleted', 'isSaving', 'hasDirtyAttributes', 'isNew');
|
||||
|
||||
@ -1009,7 +1024,7 @@ export default class LexicalEditorController extends Controller {
|
||||
return;
|
||||
} else {
|
||||
this._leaveConfirmed = true;
|
||||
transition.retry();
|
||||
return transition.retry();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user