Commit 3baefdd2 authored by Phil Hughes's avatar Phil Hughes

Fixes collapsed state loading not working with virtual scroller

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/336222
parent ad1dbf5b
...@@ -83,6 +83,7 @@ export default { ...@@ -83,6 +83,7 @@ export default {
idState() { idState() {
return { return {
isLoadingCollapsedDiff: false, isLoadingCollapsedDiff: false,
hasLoadedCollapsedDiff: false,
forkMessageVisible: false, forkMessageVisible: false,
hasToggled: false, hasToggled: false,
}; };
...@@ -181,7 +182,13 @@ export default { ...@@ -181,7 +182,13 @@ export default {
}, },
'file.file_hash': { 'file.file_hash': {
handler: function hashChangeWatch(newHash, oldHash) { handler: function hashChangeWatch(newHash, oldHash) {
if (newHash && oldHash && !this.hasDiff && !this.preRender) { if (
newHash &&
oldHash &&
!this.hasDiff &&
!this.preRender &&
!this.idState.hasLoadedCollapsedDiff
) {
this.requestDiff(); this.requestDiff();
} }
}, },
...@@ -265,14 +272,22 @@ export default { ...@@ -265,14 +272,22 @@ export default {
} }
}, },
requestDiff() { requestDiff() {
this.idState.isLoadingCollapsedDiff = true; const { idState, file } = this;
this.loadCollapsedDiff(this.file) idState.isLoadingCollapsedDiff = true;
this.loadCollapsedDiff(file)
.then(() => { .then(() => {
this.idState.isLoadingCollapsedDiff = false; idState.isLoadingCollapsedDiff = false;
this.setRenderIt(this.file); idState.hasLoadedCollapsedDiff = true;
if (this.file.file_hash === file.file_hash) {
this.setRenderIt(this.file);
}
}) })
.then(() => { .then(() => {
if (this.file.file_hash !== file.file_hash) return;
requestIdleCallback( requestIdleCallback(
() => { () => {
this.postRender(); this.postRender();
...@@ -282,7 +297,7 @@ export default { ...@@ -282,7 +297,7 @@ export default {
); );
}) })
.catch(() => { .catch(() => {
this.idState.isLoadingCollapsedDiff = false; idState.isLoadingCollapsedDiff = false;
createFlash({ createFlash({
message: this.$options.i18n.genericError, message: this.$options.i18n.genericError,
}); });
......
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