The previous behavior was causing multiple notifications

on if you switched between boards too quickly
This commit is contained in:
Zixaphir 2014-01-11 11:33:51 -07:00
parent 4ae16f4131
commit 1277d32161
3 changed files with 18 additions and 8 deletions

View File

@ -2501,7 +2501,7 @@
} }
now = Date.now(); now = Date.now();
$.ready(function() { $.ready(function() {
return setTimeout((function() { return Index.nTimeout = setTimeout((function() {
if (Index.req && !Index.notice) { if (Index.req && !Index.notice) {
return Index.notice = new Notice('info', 'Refreshing index...', 2); return Index.notice = new Notice('info', 'Refreshing index...', 2);
} }
@ -2522,9 +2522,13 @@
return $.addClass(Index.button, 'fa-spin'); return $.addClass(Index.button, 'fa-spin');
}, },
load: function(e, pageNum) { load: function(e, pageNum) {
var err, notice, req, timeEl; var err, nTimeout, notice, req, timeEl;
$.rmClass(Index.button, 'fa-spin'); $.rmClass(Index.button, 'fa-spin');
req = Index.req, notice = Index.notice; req = Index.req, notice = Index.notice, nTimeout = Index.nTimeout;
if (nTimeout) {
clearTimeout(nTimeout);
}
delete Index.nTimeout;
delete Index.req; delete Index.req;
delete Index.notice; delete Index.notice;
if (e.type === 'abort') { if (e.type === 'abort') {

View File

@ -2511,7 +2511,7 @@
} }
now = Date.now(); now = Date.now();
$.ready(function() { $.ready(function() {
return setTimeout((function() { return Index.nTimeout = setTimeout((function() {
if (Index.req && !Index.notice) { if (Index.req && !Index.notice) {
return Index.notice = new Notice('info', 'Refreshing index...', 2); return Index.notice = new Notice('info', 'Refreshing index...', 2);
} }
@ -2532,9 +2532,13 @@
return $.addClass(Index.button, 'fa-spin'); return $.addClass(Index.button, 'fa-spin');
}, },
load: function(e, pageNum) { load: function(e, pageNum) {
var err, notice, req, timeEl; var err, nTimeout, notice, req, timeEl;
$.rmClass(Index.button, 'fa-spin'); $.rmClass(Index.button, 'fa-spin');
req = Index.req, notice = Index.notice; req = Index.req, notice = Index.notice, nTimeout = Index.nTimeout;
if (nTimeout) {
clearTimeout(nTimeout);
}
delete Index.nTimeout;
delete Index.req; delete Index.req;
delete Index.notice; delete Index.notice;
if (e.type === 'abort') { if (e.type === 'abort') {

View File

@ -236,7 +236,7 @@ Index =
# This notice only displays if Index Refresh is taking too long # This notice only displays if Index Refresh is taking too long
now = Date.now() now = Date.now()
$.ready -> $.ready ->
setTimeout (-> Index.nTimeout = setTimeout (->
if Index.req and !Index.notice if Index.req and !Index.notice
Index.notice = new Notice 'info', 'Refreshing index...', 2 Index.notice = new Notice 'info', 'Refreshing index...', 2
), 3 * $.SECOND - (Date.now() - now) ), 3 * $.SECOND - (Date.now() - now)
@ -252,7 +252,9 @@ Index =
load: (e, pageNum) -> load: (e, pageNum) ->
$.rmClass Index.button, 'fa-spin' $.rmClass Index.button, 'fa-spin'
{req, notice} = Index {req, notice, nTimeout} = Index
clearTimeout nTimeout if nTimeout
delete Index.nTimeout
delete Index.req delete Index.req
delete Index.notice delete Index.notice