mirror of
https://github.com/discourse/discourse.git
synced 2025-03-23 02:25:40 +08:00
Don't request list of problems from server as often if there weren't any problems
This commit is contained in:
parent
25073e873f
commit
d0f810dee5
@ -7,6 +7,9 @@
|
|||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminDashboardRoute = Discourse.Route.extend({
|
Discourse.AdminDashboardRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
|
problemsCheckInterval: '1 minute ago',
|
||||||
|
|
||||||
setupController: function(c) {
|
setupController: function(c) {
|
||||||
this.fetchDashboardData(c);
|
this.fetchDashboardData(c);
|
||||||
this.fetchGithubCommits(c);
|
this.fetchGithubCommits(c);
|
||||||
@ -32,11 +35,17 @@ Discourse.AdminDashboardRoute = Discourse.Route.extend({
|
|||||||
c.set('problems', d.problems);
|
c.set('problems', d.problems);
|
||||||
c.set('loading', false);
|
c.set('loading', false);
|
||||||
});
|
});
|
||||||
} else if( !c.get('problemsFetchedAt') || Date.create('1 minute ago', 'en') > c.get('problemsFetchedAt') ) {
|
} else if( !c.get('problemsFetchedAt') || Date.create(this.problemsCheckInterval, 'en') > c.get('problemsFetchedAt') ) {
|
||||||
c.set('problemsFetchedAt', new Date());
|
c.set('problemsFetchedAt', new Date());
|
||||||
|
var _this = this;
|
||||||
Discourse.AdminDashboard.fetchProblems().then(function(d) {
|
Discourse.AdminDashboard.fetchProblems().then(function(d) {
|
||||||
c.set('problems', d.problems);
|
c.set('problems', d.problems);
|
||||||
c.set('loading', false);
|
c.set('loading', false);
|
||||||
|
if( d.problems && d.problems.length > 0 ) {
|
||||||
|
_this.problemsCheckInterval = '1 minute ago';
|
||||||
|
} else {
|
||||||
|
_this.problemsCheckInterval = '10 minutes ago';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user