Commit 894b6fe1 authored by Phil Hughes's avatar Phil Hughes

Fixed a bug where the index would be incorrect

parent 6783350d
......@@ -9,17 +9,19 @@ export default {
watch: {
index: {
handler() {
if (this.index < 0) return;
const { index } = this;
if (this.vscrollParent.itemsWithSize[this.index].size) {
this.scrollToIndex();
if (index < 0) return;
if (this.vscrollParent.itemsWithSize[index].size) {
this.scrollToIndex(index);
} else {
this.$_itemsWithSizeWatcher = this.$watch('vscrollParent.itemsWithSize', async () => {
await this.$nextTick();
if (this.vscrollParent.itemsWithSize[this.index].size) {
if (this.vscrollParent.itemsWithSize[index].size) {
this.$_itemsWithSizeWatcher();
this.scrollToIndex();
this.scrollToIndex(index);
}
});
}
......@@ -31,8 +33,8 @@ export default {
if (this.$_itemsWithSizeWatcher) this.$_itemsWithSizeWatcher();
},
methods: {
scrollToIndex() {
this.vscrollParent.scrollToItem(this.index);
scrollToIndex(index) {
this.vscrollParent.scrollToItem(index);
},
},
render(h) {
......
......@@ -125,6 +125,11 @@ export const fetchDiffFilesBatch = ({ commit, state, dispatch }) => {
commit(types.SET_DIFF_DATA_BATCH, { diff_files });
commit(types.SET_BATCH_LOADING, false);
eventHub.$emit(
'scrollToFileHash',
window.location.hash.replace('#', '').split('diff-content-').pop(),
);
if (!isNoteLink && !state.currentDiffFileId) {
commit(types.VIEW_DIFF_FILE, diff_files[0].file_hash);
}
......@@ -190,12 +195,6 @@ export const fetchDiffFilesBatch = ({ commit, state, dispatch }) => {
return getBatch()
.then(() => !window.gon?.features?.diffsVirtualScrolling && handleLocationHash())
.then(() => {
eventHub.$emit(
'scrollToFileHash',
window.location.hash.replace('#', '').split('diff-content-').pop(),
);
})
.catch(() => null);
};
......
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