Commit 39bbbcae authored by Mike Greiling's avatar Mike Greiling

Merge branch 'ph/fixBatchDiffsDiscussionsNotShowing' into 'master'

Fixes issue where discussions would not be assigned with batch diffs

See merge request gitlab-org/gitlab!22982
parents c46cc334 82414aae
...@@ -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);
......
...@@ -77,6 +77,7 @@ describe('diffs/components/app', () => { ...@@ -77,6 +77,7 @@ describe('diffs/components/app', () => {
beforeEach(done => { beforeEach(done => {
const fetchResolver = () => { const fetchResolver = () => {
store.state.diffs.retrievingBatches = false; store.state.diffs.retrievingBatches = false;
store.state.notes.discussions = 'test';
return Promise.resolve({ real_size: 100 }); return Promise.resolve({ real_size: 100 });
}; };
spyOn(window, 'requestIdleCallback').and.callFake(fn => fn()); spyOn(window, 'requestIdleCallback').and.callFake(fn => fn());
...@@ -87,6 +88,7 @@ describe('diffs/components/app', () => { ...@@ -87,6 +88,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 +242,7 @@ describe('diffs/components/app', () => { ...@@ -240,6 +242,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 +261,7 @@ describe('diffs/components/app', () => { ...@@ -258,6 +261,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 +278,7 @@ describe('diffs/components/app', () => { ...@@ -274,6 +278,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