diff options
author | Regis <boudinot.regis@yahoo.com> | 2016-12-02 15:05:01 -0700 |
---|---|---|
committer | Regis <boudinot.regis@yahoo.com> | 2016-12-02 15:05:01 -0700 |
commit | d6061b739b7f27d9b7ee9f6ff1e7a635c7bac0b3 (patch) | |
tree | a29a92195190514b5eb3172e73ef5880a02107b8 /app/assets/javascripts/vue_pipelines_index/store.js.es6 | |
parent | 004a9c6bccb840b97616d25c0ff24a8de62ff496 (diff) | |
download | gitlab-ce-d6061b739b7f27d9b7ee9f6ff1e7a635c7bac0b3.tar.gz |
much simpler time logic - clean up - [ci skip]
Diffstat (limited to 'app/assets/javascripts/vue_pipelines_index/store.js.es6')
-rw-r--r-- | app/assets/javascripts/vue_pipelines_index/store.js.es6 | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/app/assets/javascripts/vue_pipelines_index/store.js.es6 b/app/assets/javascripts/vue_pipelines_index/store.js.es6 index ca537a9c20d..1a473c51521 100644 --- a/app/assets/javascripts/vue_pipelines_index/store.js.es6 +++ b/app/assets/javascripts/vue_pipelines_index/store.js.es6 @@ -1,5 +1,5 @@ /* global gl, Flash */ -/* eslint-disable no-param-reassign */ +/* eslint-disable no-param-reassign, no-underscore-dangle */ ((gl) => { gl.PipelineStore = class { @@ -43,25 +43,36 @@ resourceChecker(); goFetch(); - const removePipelineIntervals = () => { - this.allTimeIntervals.forEach(e => clearInterval(e.id)); + const startTimeLoops = () => { + this.timeLoopInterval = setInterval(() => { + console.log('TIME LOOP'); + this.$children + .filter(e => e.$options._componentTag === 'time-ago') + .forEach(e => e.changeTime()); + }, 1000); + }; + + startTimeLoops(); + + const removeTimeIntervals = () => { + clearInterval(this.timeLoopInterval); }; const startIntervalLoops = () => { - this.allTimeIntervals.forEach(e => e.start()); + startTimeLoops(); }; const removeAll = () => { - removePipelineIntervals(); - window.removeEventListener('beforeunload', () => {}); - window.removeEventListener('focus', () => {}); - window.removeEventListener('blur', () => {}); - document.removeEventListener('page:fetch', () => {}); + removeTimeIntervals(); + window.removeEventListener('beforeunload', removeTimeIntervals); + window.removeEventListener('focus', startIntervalLoops); + window.removeEventListener('blur', removeTimeIntervals); + document.removeEventListener('page:fetch', removeTimeIntervals); }; - window.addEventListener('beforeunload', removePipelineIntervals); + window.addEventListener('beforeunload', removeTimeIntervals); window.addEventListener('focus', startIntervalLoops); - window.addEventListener('blur', removePipelineIntervals); + window.addEventListener('blur', removeTimeIntervals); document.addEventListener('page:fetch', removeAll); } }; |