0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Fixed confusing editor state after a failed status change

no issue

- post status was not being reset after certain types of failure to publish/unpublish/schedule which meant that the editor could be left in an odd in-between state where the displayed status did not reflect reality
- fixed "saving/publish/schedule failed:" wording in error message when a server unreachable error was detected, the "saving/publish/schedule" did not reflect the actual status change because we were passing through only the current status rather than previous+new status'
This commit is contained in:
Kevin Ansfield 2021-06-28 15:28:50 +01:00
parent a6c6def7e1
commit 53dbbf33a5

View file

@ -491,6 +491,8 @@ export default Controller.extend({
return post;
} catch (error) {
this.set('post.status', prevStatus);
if (error === undefined) {
// validation error or "handled" error from _saveTask
return;
@ -510,8 +512,6 @@ export default Controller.extend({
return;
}
this.set('post.status', prevStatus);
if (!options.silent) {
let errorOrMessages = error || this.get('post.errors.messages');
this._showErrorAlert(prevStatus, this.get('post.status'), errorOrMessages);
@ -625,8 +625,8 @@ export default Controller.extend({
if (isServerUnreachableError(error) && attempts < maxAttempts) {
yield timeout(5 * 1000);
} else if (isServerUnreachableError(error)) {
const status = this.post.status;
this._showErrorAlert(status, status, error);
const [prevStatus, newStatus] = this.post.changedAttributes().status || [this.post.status, this.post.status];
this._showErrorAlert(prevStatus, newStatus, error);
if (this.config.get('sentry_dsn')) {
captureException(error);
}