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 {
},
isLoading: 'adjustView',
showTreeList: 'adjustView',
retrievingBatches(newVal) {
if (!newVal) this.unwatchDiscussions();
},
},
mounted() {
this.setBaseConfig({
......@@ -198,6 +195,16 @@ export default {
() => `${this.diffFiles.length}:${this.$store.state.notes.discussions.length}`,
() => 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() {
eventHub.$off('fetchDiffData', this.fetchData);
......
......@@ -77,6 +77,7 @@ describe('diffs/components/app', () => {
beforeEach(done => {
const fetchResolver = () => {
store.state.diffs.retrievingBatches = false;
store.state.notes.discussions = 'test';
return Promise.resolve({ real_size: 100 });
};
spyOn(window, 'requestIdleCallback').and.callFake(fn => fn());
......@@ -87,6 +88,7 @@ describe('diffs/components/app', () => {
spyOn(wrapper.vm, 'setDiscussions');
spyOn(wrapper.vm, 'startRenderDiffsQueue');
spyOn(wrapper.vm, 'unwatchDiscussions');
spyOn(wrapper.vm, 'unwatchRetrievingBatches');
store.state.diffs.retrievingBatches = true;
store.state.diffs.diffFiles = [];
wrapper.vm.$nextTick(done);
......@@ -240,6 +242,7 @@ describe('diffs/components/app', () => {
expect(wrapper.vm.fetchDiffFilesBatch).not.toHaveBeenCalled();
expect(wrapper.vm.unwatchDiscussions).toHaveBeenCalled();
expect(wrapper.vm.diffFilesLength).toEqual(100);
expect(wrapper.vm.unwatchRetrievingBatches).toHaveBeenCalled();
done();
});
......@@ -258,6 +261,7 @@ describe('diffs/components/app', () => {
expect(wrapper.vm.fetchDiffFilesBatch).toHaveBeenCalled();
expect(wrapper.vm.unwatchDiscussions).toHaveBeenCalled();
expect(wrapper.vm.diffFilesLength).toEqual(100);
expect(wrapper.vm.unwatchRetrievingBatches).toHaveBeenCalled();
done();
});
});
......@@ -274,6 +278,7 @@ describe('diffs/components/app', () => {
expect(wrapper.vm.fetchDiffFilesBatch).toHaveBeenCalled();
expect(wrapper.vm.unwatchDiscussions).toHaveBeenCalled();
expect(wrapper.vm.diffFilesLength).toEqual(100);
expect(wrapper.vm.unwatchRetrievingBatches).toHaveBeenCalled();
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