mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-04 02:01:58 -05:00
Auto trigger Post analytics refresh (#21930)
ref https://linear.app/ghost/issue/DES-1041/auto-refresh-post-analytics At the moment have a Refresh button in Post analytics which requires users manually clicking to see how data updates on the page. This PR is about automatically trigger this "click" every [10 seconds] so that the refresh happens without users having to click.
This commit is contained in:
parent
8846b97568
commit
9082a9f1db
2 changed files with 12 additions and 9 deletions
|
@ -35,14 +35,6 @@
|
|||
{{/let}}
|
||||
</div>
|
||||
<div style="display: flex; gap: 8px;">
|
||||
<GhTaskButton
|
||||
@buttonText="Refresh"
|
||||
@task={{this.fetchPostTask}}
|
||||
@showIcon={{true}}
|
||||
@idleIcon="reload"
|
||||
@successText="Refreshed"
|
||||
@class="gh-btn gh-btn-icon refresh"
|
||||
@successClass="gh-btn gh-btn-icon refresh" />
|
||||
{{#unless this.post.emailOnly}}
|
||||
<button type="button" class="gh-btn gh-btn-icon share" {{on "click" this.togglePublishFlowModal}}>
|
||||
<span>{{svg-jar "share" title="Share post"}} Share</span>
|
||||
|
|
|
@ -3,7 +3,7 @@ import DeletePostModal from '../modals/delete-post';
|
|||
import PostSuccessModal from '../modal-post-success';
|
||||
import anime from 'animejs/lib/anime.es.js';
|
||||
import {action} from '@ember/object';
|
||||
import {didCancel, task} from 'ember-concurrency';
|
||||
import {didCancel, task, timeout} from 'ember-concurrency';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
|
||||
|
@ -19,6 +19,8 @@ const DISPLAY_OPTIONS = [{
|
|||
value: 'paid'
|
||||
}];
|
||||
|
||||
const AUTO_REFRESH_RATE = 7500;
|
||||
|
||||
export default class Analytics extends Component {
|
||||
@service ajax;
|
||||
@service ghostPaths;
|
||||
|
@ -51,6 +53,8 @@ export default class Analytics extends Component {
|
|||
constructor() {
|
||||
super(...arguments);
|
||||
this.checkPublishFlowModal();
|
||||
this.fetchPostTask.perform();
|
||||
this.autoRefreshTask.perform();
|
||||
}
|
||||
|
||||
openPublishFlowModal() {
|
||||
|
@ -390,6 +394,13 @@ export default class Analytics extends Component {
|
|||
return true;
|
||||
}
|
||||
|
||||
@task
|
||||
*autoRefreshTask() {
|
||||
yield timeout(AUTO_REFRESH_RATE);
|
||||
yield this.fetchPostTask.perform();
|
||||
this.autoRefreshTask.perform();
|
||||
}
|
||||
|
||||
@action
|
||||
applyClasses(element) {
|
||||
if (!this.shouldAnimate ||
|
||||
|
|
Loading…
Add table
Reference in a new issue