Skip to content

Commit d4f30bb

Browse files
committed
Restore function to Show more button
There was a serious regression in go-gitea#21012 which broke the Show More button on the diff page, and the show more button was also broken on the file tree too. This PR fixes this by resetting the pageData.diffFiles as the vue watched value and reattachs a function to the show more button outside of the file tree view. Fix go-gitea#22380 Signed-off-by: Andrew Thornton <[email protected]>
1 parent e7f1d45 commit d4f30bb

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

web_src/js/components/DiffFileTree.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default {
2929
},
3030
computed: {
3131
fileTree() {
32+
pageData.diffFileInfo.files = this.files;
3233
const result = [];
3334
for (const file of this.files) {
3435
// Split file into directories

web_src/js/features/repo-diff.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,25 +119,46 @@ function onShowMoreFiles() {
119119

120120
export function doLoadMoreFiles(link, diffEnd, callback) {
121121
const url = `${link}?skip-to=${diffEnd}&file-only=true`;
122+
loadMoreFiles(url, callback);
123+
}
124+
125+
function loadMoreFiles(url, callback) {
126+
const $target = $('a#diff-show-more-files');
127+
if ($target.hasClass('disabled')) {
128+
callback();
129+
return;
130+
}
131+
$target.addClass('disabled');
122132
$.ajax({
123133
type: 'GET',
124134
url,
125135
}).done((resp) => {
126136
if (!resp) {
137+
$target.removeClass('disabled');
127138
callback(resp);
128139
return;
129140
}
141+
$('#diff-incomplete').replaceWith($(resp).find('#diff-file-boxes').children());
130142
// By simply rerunning the script we add the new data to our existing
131143
// pagedata object. this triggers vue and the filetree and filelist will
132144
// render the new elements.
133145
$('body').append($(resp).find('script#diff-data-script'));
146+
onShowMoreFiles();
134147
callback(resp);
135148
}).fail(() => {
149+
$target.removeClass('disabled');
136150
callback();
137151
});
138152
}
139153

140154
export function initRepoDiffShowMore() {
155+
$(document).on('click', 'a#diff-show-more-files', (e) => {
156+
e.preventDefault();
157+
158+
const $target = $(e.target);
159+
loadMoreFiles($target.data('href'), () => {});
160+
});
161+
141162
$(document).on('click', 'a.diff-show-more-button', (e) => {
142163
e.preventDefault();
143164
const $target = $(e.target);

0 commit comments

Comments
 (0)