Skip to content

Commit 4088e58

Browse files
fix: Schedule publish toggle crash (#4878)
1 parent 8b23d6f commit 4088e58

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

app/controllers/events/view/scheduler.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -111,28 +111,27 @@ export default class extends Controller {
111111
}
112112

113113
@action
114-
togglePublishState() {
114+
async togglePublishState() {
115115
this.set('isLoading', true);
116116
const stat = this.isSchedulePublished ? 'unpublished' : 'published';
117117
const publishedAt = this.isSchedulePublished ? moment(0) : moment();
118-
const event = this.model.eventDetails;
118+
const { event } = this.model;
119119
event.set('schedulePublishedOn', publishedAt);
120-
event.save()
121-
.then(() => {
122-
this.notify.success(`The schedule has been ${stat} successfully`,
123-
{
124-
id: 'schedule_change_succ'
125-
});
126-
})
127-
.catch(reason => {
128-
this.set('error', reason);
129-
this.notify.error(`Error: ${reason}`,
130-
{
131-
id: 'error_reason_scheduler'
132-
});
133-
})
134-
.finally(() => {
135-
this.set('isLoading', false);
136-
});
120+
try {
121+
await event.save();
122+
this.notify.success(`The schedule has been ${stat} successfully`,
123+
{
124+
id: 'schedule_change_succ'
125+
});
126+
} catch (e) {
127+
console.error('Error while toggling schedule publish state', e);
128+
this.set('error', e);
129+
this.notify.error(`Error: ${e}`,
130+
{
131+
id: 'error_reason_scheduler'
132+
});
133+
} finally {
134+
this.set('isLoading', false);
135+
}
137136
}
138137
}

0 commit comments

Comments
 (0)