Commit 60e44ba9 authored by Phil Hughes's avatar Phil Hughes Committed by jboyson1

Fixes issue where discussions would not be assigned with batch diffs

This fixes an issue where discussions can sometimes take longer
to load and then won't be assigned to the lines in diffs
parent a1b4efcc
...@@ -163,9 +163,6 @@ export default { ...@@ -163,9 +163,6 @@ export default {
}, },
isLoading: 'adjustView', isLoading: 'adjustView',
showTreeList: 'adjustView', showTreeList: 'adjustView',
retrievingBatches(newVal) {
if (!newVal) this.unwatchDiscussions();
},
}, },
mounted() { mounted() {
this.setBaseConfig({ this.setBaseConfig({
...@@ -198,6 +195,16 @@ export default { ...@@ -198,6 +195,16 @@ export default {
() => `${this.diffFiles.length}:${this.$store.state.notes.discussions.length}`, () => `${this.diffFiles.length}:${this.$store.state.notes.discussions.length}`,
() => this.setDiscussions(), () => this.setDiscussions(),
); );
this.unwatchRetrievingBatches = this.$watch(
() => `${this.retrievingBatches}:${this.$store.state.notes.discussions.length}`,
() => {
if (!this.retrievingBatches && this.$store.state.notes.discussions.length) {
this.unwatchDiscussions();
this.unwatchRetrievingBatches();
}
},
);
}, },
beforeDestroy() { beforeDestroy() {
eventHub.$off('fetchDiffData', this.fetchData); eventHub.$off('fetchDiffData', this.fetchData);
......
...@@ -87,6 +87,7 @@ describe('diffs/components/app', () => { ...@@ -87,6 +87,7 @@ describe('diffs/components/app', () => {
spyOn(wrapper.vm, 'setDiscussions'); spyOn(wrapper.vm, 'setDiscussions');
spyOn(wrapper.vm, 'startRenderDiffsQueue'); spyOn(wrapper.vm, 'startRenderDiffsQueue');
spyOn(wrapper.vm, 'unwatchDiscussions'); spyOn(wrapper.vm, 'unwatchDiscussions');
spyOn(wrapper.vm, 'unwatchRetrievingBatches');
store.state.diffs.retrievingBatches = true; store.state.diffs.retrievingBatches = true;
store.state.diffs.diffFiles = []; store.state.diffs.diffFiles = [];
wrapper.vm.$nextTick(done); wrapper.vm.$nextTick(done);
...@@ -240,6 +241,7 @@ describe('diffs/components/app', () => { ...@@ -240,6 +241,7 @@ describe('diffs/components/app', () => {
expect(wrapper.vm.fetchDiffFilesBatch).not.toHaveBeenCalled(); expect(wrapper.vm.fetchDiffFilesBatch).not.toHaveBeenCalled();
expect(wrapper.vm.unwatchDiscussions).toHaveBeenCalled(); expect(wrapper.vm.unwatchDiscussions).toHaveBeenCalled();
expect(wrapper.vm.diffFilesLength).toEqual(100); expect(wrapper.vm.diffFilesLength).toEqual(100);
expect(wrapper.vm.unwatchRetrievingBatches).toHaveBeenCalled();
done(); done();
}); });
...@@ -258,6 +260,7 @@ describe('diffs/components/app', () => { ...@@ -258,6 +260,7 @@ describe('diffs/components/app', () => {
expect(wrapper.vm.fetchDiffFilesBatch).toHaveBeenCalled(); expect(wrapper.vm.fetchDiffFilesBatch).toHaveBeenCalled();
expect(wrapper.vm.unwatchDiscussions).toHaveBeenCalled(); expect(wrapper.vm.unwatchDiscussions).toHaveBeenCalled();
expect(wrapper.vm.diffFilesLength).toEqual(100); expect(wrapper.vm.diffFilesLength).toEqual(100);
expect(wrapper.vm.unwatchRetrievingBatches).toHaveBeenCalled();
done(); done();
}); });
}); });
...@@ -274,6 +277,7 @@ describe('diffs/components/app', () => { ...@@ -274,6 +277,7 @@ describe('diffs/components/app', () => {
expect(wrapper.vm.fetchDiffFilesBatch).toHaveBeenCalled(); expect(wrapper.vm.fetchDiffFilesBatch).toHaveBeenCalled();
expect(wrapper.vm.unwatchDiscussions).toHaveBeenCalled(); expect(wrapper.vm.unwatchDiscussions).toHaveBeenCalled();
expect(wrapper.vm.diffFilesLength).toEqual(100); expect(wrapper.vm.diffFilesLength).toEqual(100);
expect(wrapper.vm.unwatchRetrievingBatches).toHaveBeenCalled();
done(); done();
}); });
}); });
......
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