mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-02 08:13:34 +03:00
1f2857e0e4
no issue When we open the editor, we fire 4 requests to fetch member counts. This commit fixes this by replacing those calls with the members count cache service.
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
import PublishOptions from '../utils/publish-options';
|
|
import {Resource} from 'ember-could-get-used-to-this';
|
|
import {inject} from 'ghost-admin/decorators/inject';
|
|
import {inject as service} from '@ember/service';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class PublishOptionsResource extends Resource {
|
|
@service limit;
|
|
@service session;
|
|
@service settings;
|
|
@service store;
|
|
@service membersCountCache;
|
|
|
|
@inject config;
|
|
|
|
@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) {
|
|
const {config, limit, settings, store, membersCountCache} = this;
|
|
|
|
return new PublishOptions({
|
|
config,
|
|
limit,
|
|
post,
|
|
settings,
|
|
store,
|
|
membersCountCache,
|
|
user: this.session.user
|
|
});
|
|
}
|
|
}
|