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';
|
2022-11-03 14:14:36 +03:00
|
|
|
import {inject} from 'ghost-admin/decorators/inject';
|
2022-04-22 19:56:05 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
|
|
|
|
export default class PublishOptionsResource extends Resource {
|
2022-05-11 19:00:20 +03:00
|
|
|
@service limit;
|
2022-04-22 19:56:05 +03:00
|
|
|
@service session;
|
|
|
|
@service settings;
|
|
|
|
@service store;
|
2024-01-13 21:13:49 +03:00
|
|
|
@service membersCountCache;
|
2022-04-22 19:56:05 +03:00
|
|
|
|
2022-11-03 14:14:36 +03:00
|
|
|
@inject config;
|
|
|
|
|
2022-04-22 19:56:05 +03:00
|
|
|
@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) {
|
2024-01-13 21:13:49 +03:00
|
|
|
const {config, limit, settings, store, membersCountCache} = 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,
|
2024-01-13 21:13:49 +03:00
|
|
|
membersCountCache,
|
2022-04-22 19:56:05 +03:00
|
|
|
user: this.session.user
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|