Commit d4a6411b authored by Mike Greiling's avatar Mike Greiling

fix pipelines_store

parent 8516e113
...@@ -26,7 +26,7 @@ class PipelinesStore { ...@@ -26,7 +26,7 @@ class PipelinesStore {
*/ */
startTimeAgoLoops() { startTimeAgoLoops() {
const startTimeLoops = () => { const startTimeLoops = () => {
this.timeLoopInterval = setInterval(function timeloopInterval() { this.timeLoopInterval = setInterval(() => {
this.$children[0].$children.reduce((acc, component) => { this.$children[0].$children.reduce((acc, component) => {
const timeAgoComponent = component.$children.filter(el => el.$options._componentTag === 'time-ago')[0]; const timeAgoComponent = component.$children.filter(el => el.$options._componentTag === 'time-ago')[0];
acc.push(timeAgoComponent); acc.push(timeAgoComponent);
......
...@@ -14,5 +14,16 @@ ...@@ -14,5 +14,16 @@
window.addEventListener('focus', startIntervals); window.addEventListener('focus', startIntervals);
window.addEventListener('blur', removeIntervals); window.addEventListener('blur', removeIntervals);
document.addEventListener('beforeunload', removeAll); document.addEventListener('beforeunload', removeAll);
// add removeAll methods to stack
const stack = gl.VueRealtimeListener.reset;
gl.VueRealtimeListener.reset = () => {
gl.VueRealtimeListener.reset = stack;
removeAll();
stack();
};
}; };
// remove all event listeners and intervals
gl.VueRealtimeListener.reset = () => undefined; // noop
})(window.gl || (window.gl = {})); })(window.gl || (window.gl = {}));
...@@ -7,6 +7,9 @@ describe('Store', () => { ...@@ -7,6 +7,9 @@ describe('Store', () => {
store = new gl.commits.pipelines.PipelinesStore(); store = new gl.commits.pipelines.PipelinesStore();
}); });
// unregister intervals and event handlers
afterEach(() => gl.VueRealtimeListener.reset());
it('should start with a blank state', () => { it('should start with a blank state', () => {
expect(store.state.pipelines.length).toBe(0); expect(store.state.pipelines.length).toBe(0);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment