2022-09-09 19:13:07 +03:00
|
|
|
import Controller from '@ember/controller';
|
2022-02-01 12:34:03 +03:00
|
|
|
import {action} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
2021-10-18 15:46:29 +03:00
|
|
|
import {task} from 'ember-concurrency';
|
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
export default class UnsplashController extends Controller {
|
2022-02-01 20:03:45 +03:00
|
|
|
@service notifications;
|
|
|
|
@service settings;
|
2021-10-18 15:46:29 +03:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
@action
|
|
|
|
update(value) {
|
|
|
|
this.settings.set('unsplash', value);
|
|
|
|
}
|
2021-10-18 15:46:29 +03:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
@action
|
|
|
|
save() {
|
2022-02-10 13:20:03 +03:00
|
|
|
this.saveTask.perform();
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|
2021-10-18 15:46:29 +03:00
|
|
|
|
2022-09-09 19:13:07 +03:00
|
|
|
@task({drop: true})
|
|
|
|
*saveTask() {
|
2021-10-18 15:46:29 +03:00
|
|
|
try {
|
|
|
|
yield this.settings.validate();
|
|
|
|
return yield this.settings.save();
|
|
|
|
} catch (error) {
|
|
|
|
this.notifications.showAPIError(error);
|
|
|
|
throw error;
|
|
|
|
}
|
2022-09-09 19:13:07 +03:00
|
|
|
}
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|