2022-05-11 19:51:53 +03:00
|
|
|
import PublishOptions from '../utils/publish-options';
|
2022-04-22 19:56:05 +03:00
|
|
|
import {Resource} from 'ember-could-get-used-to-this';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
|
|
|
|
export default class PublishOptionsResource extends Resource {
|
|
|
|
@service config;
|
2022-05-11 19:00:20 +03:00
|
|
|
@service limit;
|
2022-04-22 19:56:05 +03:00
|
|
|
@service session;
|
|
|
|
@service settings;
|
|
|
|
@service store;
|
|
|
|
|
|
|
|
@tracked publishOptions;
|
|
|
|
|
|
|
|
get value() {
|
|
|
|
return this.publishOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
const post = this.args.positional[0];
|
|
|
|
this._post = post;
|
|
|
|
|
|
|
|
this.publishOptions = this._createPublishOptions(post);
|
|
|
|
}
|
|
|
|
|
|
|
|
update() {
|
|
|
|
// required due to a weird invalidation issue when using Ember Data with ember-could-get-used-to-this
|
|
|
|
// TODO: re-test after upgrading to ember-resources
|
|
|
|
const post = this.args.positional[0];
|
|
|
|
if (post !== this._post) {
|
|
|
|
this.publishOptions = this._createPublishOptions(post);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_createPublishOptions(post) {
|
2022-05-11 19:00:20 +03:00
|
|
|
const {config, limit, settings, store} = this;
|
2022-04-22 19:56:05 +03:00
|
|
|
|
|
|
|
return new PublishOptions({
|
|
|
|
config,
|
2022-05-11 19:00:20 +03:00
|
|
|
limit,
|
2022-04-22 19:56:05 +03:00
|
|
|
post,
|
|
|
|
settings,
|
|
|
|
store,
|
|
|
|
user: this.session.user
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|