forked from forgejo/forgejo
Backport #22399 There was a serious regression in #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 #22380 Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
426c0ad14c
commit
421d87933b
4 changed files with 30 additions and 3 deletions
|
@ -119,26 +119,47 @@ function onShowMoreFiles() {
|
|||
|
||||
export function doLoadMoreFiles(link, diffEnd, callback) {
|
||||
const url = `${link}?skip-to=${diffEnd}&file-only=true`;
|
||||
loadMoreFiles(url, callback);
|
||||
}
|
||||
|
||||
function loadMoreFiles(url, callback) {
|
||||
const $target = $('a#diff-show-more-files');
|
||||
if ($target.hasClass('disabled')) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
$target.addClass('disabled');
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url,
|
||||
}).done((resp) => {
|
||||
if (!resp) {
|
||||
$target.removeClass('disabled');
|
||||
callback(resp);
|
||||
return;
|
||||
}
|
||||
$('#diff-incomplete').replaceWith($(resp).find('#diff-file-boxes').children());
|
||||
// By simply rerunning the script we add the new data to our existing
|
||||
// pagedata object. this triggers vue and the filetree and filelist will
|
||||
// render the new elements.
|
||||
$('body').append($(resp).find('script#diff-data-script'));
|
||||
onShowMoreFiles();
|
||||
callback(resp);
|
||||
}).fail(() => {
|
||||
$target.removeClass('disabled');
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
export function initRepoDiffShowMore() {
|
||||
$(document).on('click', 'a.diff-show-more-button', (e) => {
|
||||
$(document).on('click', 'a#diff-show-more-files', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const $target = $(e.target);
|
||||
loadMoreFiles($target.data('href'), () => {});
|
||||
});
|
||||
|
||||
$(document).on('click', 'a.diff-load-button', (e) => {
|
||||
e.preventDefault();
|
||||
const $target = $(e.target);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue