File tree Expand file tree Collapse file tree 1 file changed +18
-19
lines changed
app/controllers/events/view Expand file tree Collapse file tree 1 file changed +18
-19
lines changed Original file line number Diff line number Diff line change @@ -111,28 +111,27 @@ export default class extends Controller {
111
111
}
112
112
113
113
@action
114
- togglePublishState ( ) {
114
+ async togglePublishState ( ) {
115
115
this . set ( 'isLoading' , true ) ;
116
116
const stat = this . isSchedulePublished ? 'unpublished' : 'published' ;
117
117
const publishedAt = this . isSchedulePublished ? moment ( 0 ) : moment ( ) ;
118
- const event = this . model . eventDetails ;
118
+ const { event } = this . model ;
119
119
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
+ }
137
136
}
138
137
}
You can’t perform that action at this time.
0 commit comments