Commit 08bfdf81 authored by Jacques's avatar Jacques

Load diff stats for async diffs

Ensures diff stats are alsos loaded for async diffs
parent 21c8b38c
...@@ -27,28 +27,10 @@ initCommitBoxInfo(); ...@@ -27,28 +27,10 @@ initCommitBoxInfo();
initDeprecatedNotes(); initDeprecatedNotes();
const filesContainer = $('.js-diffs-batch'); const loadDiffStats = () => {
const diffStatsElements = document.querySelectorAll('#js-diff-stats'); const diffStatsElements = document.querySelectorAll('#js-diff-stats');
if (filesContainer.length) {
const batchPath = filesContainer.data('diffFilesPath');
axios
.get(batchPath)
.then(({ data }) => {
filesContainer.html($(data));
syntaxHighlight(filesContainer);
handleLocationHash();
new Diff();
})
.catch(() => {
createFlash({ message: __('An error occurred while retrieving diff files') });
});
} else {
new Diff();
}
if (diffStatsElements.length) { if (diffStatsElements.length) {
diffStatsElements.forEach((diffStatsEl) => { diffStatsElements.forEach((diffStatsEl) => {
const { addedLines, removedLines, oldSize, newSize, viewerName } = diffStatsEl.dataset; const { addedLines, removedLines, oldSize, newSize, viewerName } = diffStatsEl.dataset;
...@@ -69,6 +51,29 @@ if (diffStatsElements.length) { ...@@ -69,6 +51,29 @@ if (diffStatsElements.length) {
}, },
}); });
}); });
}
};
const filesContainer = $('.js-diffs-batch');
if (filesContainer.length) {
const batchPath = filesContainer.data('diffFilesPath');
axios
.get(batchPath)
.then(({ data }) => {
filesContainer.html($(data));
syntaxHighlight(filesContainer);
handleLocationHash();
new Diff();
loadDiffStats();
})
.catch(() => {
createFlash({ message: __('An error occurred while retrieving diff files') });
});
} else {
new Diff();
loadDiffStats();
} }
loadAwardsHandler(); loadAwardsHandler();
......
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