0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Fixed email error flash on the publish flow (#21706)

ref DES-990

- previously, the publish flow was continued regardless of if there was an error while sending email
- now it correctly stays on the error state, and goes to the normal flow once the error is fixed and retried
This commit is contained in:
Sodbileg Gansukh 2024-12-02 11:07:14 +08:00 committed by GitHub
parent 04ed106c73
commit 9054781212
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 38 additions and 39 deletions

View file

@ -41,10 +41,10 @@
@publishOptions={{@data.publishOptions}}
@recipientType={{this.recipientType}}
@saveTask={{this.saveTask}}
@setCompleted={{this.setCompleted}}
@cancel={{this.toggleConfirm}}
@close={{@close}}
/>
{{else if this.isComplete}}
{{else}}
<Editor::Modals::PublishFlow::Options
@publishOptions={{@data.publishOptions}}

View file

@ -12,6 +12,7 @@ export default class PublishModalComponent extends Component {
};
@service store;
@service router;
@tracked emailErrorMessage = this.args.data.publishOptions.post.didEmailFail ? (this.args.data.publishOptions.post.email.error ?? 'Unknown error') : undefined;
@tracked isConfirming = false;
@ -52,20 +53,51 @@ export default class PublishModalComponent extends Component {
@action
setCompleted() {
this.emailErrorMessage = undefined;
this.isConfirming = false;
this.isComplete = true;
if (this.args.data.publishOptions.isScheduled) {
try {
localStorage.setItem('ghost-last-scheduled-post', JSON.stringify({
id: this.args.data.publishOptions.post.id,
type: this.args.data.publishOptions.post.displayName
}));
} catch (e) {
// ignore localStorage errors
}
if (this.args.data.publishOptions.post.displayName !== 'page') {
this.router.transitionTo('posts');
} else {
this.router.transitionTo('pages');
}
} else {
try {
localStorage.setItem('ghost-last-published-post', JSON.stringify({
id: this.args.data.publishOptions.post.id,
type: this.args.data.publishOptions.post.displayName
}));
} catch (e) {
// ignore localStorage errors
}
if (this.args.data.publishOptions.post.displayName !== 'page') {
if (this.args.data.publishOptions.post.hasEmail) {
this.router.transitionTo('posts.analytics', this.args.data.publishOptions.post.id);
} else {
this.router.transitionTo('posts');
}
} else {
this.router.transitionTo('pages');
}
}
}
@task
*saveTask() {
try {
yield this.args.data.saveTask.perform();
this.isConfirming = false;
this.isComplete = true;
} catch (e) {
if (e?.name === 'EmailFailedError') {
return this.emailErrorMessage = e.message;
this.emailErrorMessage = e.message;
}
throw e;

View file

@ -93,40 +93,7 @@ export default class PublishFlowOptions extends Component {
try {
yield this.args.saveTask.perform();
if (this.args.publishOptions.isScheduled) {
try {
localStorage.setItem('ghost-last-scheduled-post', JSON.stringify({
id: this.args.publishOptions.post.id,
type: this.args.publishOptions.post.displayName
}));
} catch (e) {
// ignore localStorage errors
}
if (this.args.publishOptions.post.displayName !== 'page') {
this.router.transitionTo('posts');
} else {
this.router.transitionTo('pages');
}
} else {
try {
localStorage.setItem('ghost-last-published-post', JSON.stringify({
id: this.args.publishOptions.post.id,
type: this.args.publishOptions.post.displayName
}));
} catch (e) {
// ignore localStorage errors
}
if (this.args.publishOptions.post.displayName !== 'page') {
if (this.args.publishOptions.post.hasEmail) {
this.router.transitionTo('posts.analytics', this.args.publishOptions.post.id);
} else {
this.router.transitionTo('posts');
}
} else {
this.router.transitionTo('pages');
}
}
this.args.setCompleted();
} catch (e) {
if (e === undefined && this.args.publishOptions.post.errors.length !== 0) {
// validation error