1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/components/modal-delete-member.js
Kevin Ansfield 80346e4868 Memoized member stats with expiration
no issue

- added a `member-stats` service to keep member stats state outside of the chart component's lifecycle
- returns memoized member stats when fetching if the query hasn't changed and the data is less than a minute old
- reduces potentially heavy network requests when quickly navigating between members list and other screens
2020-05-26 17:17:52 +01:00

29 lines
655 B
JavaScript

import ModalComponent from 'ghost-admin/components/modal-base';
import {alias} from '@ember/object/computed';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency';
export default ModalComponent.extend({
membersStats: service(),
// Allowed actions
confirm: () => {},
member: alias('model'),
actions: {
confirm() {
this.deleteMember.perform();
}
},
deleteMember: task(function* () {
try {
yield this.confirm();
this.membersStats.invalidate();
} finally {
this.send('closeModal');
}
}).drop()
});