]> source.dussan.org Git - gitea.git/commitdiff
make `show stats` work when only one file changed (#32244)
authora1012112796 <1012112796@qq.com>
Mon, 14 Oct 2024 21:23:20 +0000 (05:23 +0800)
committerGitHub <noreply@github.com>
Mon, 14 Oct 2024 21:23:20 +0000 (21:23 +0000)
fix https://github.com/go-gitea/gitea/issues/32226

in https://github.com/go-gitea/gitea/pull/27775 , it do some changes to
only show diff file tree when more than one file changed. But looks it
also break the `diff-file-list` logic, which looks not expected change.
so try fix it.

/cc @silverwind

example view:

![image](https://github.com/user-attachments/assets/281e9c4f-a269-4d36-94eb-a132058aea87)

Signed-off-by: a1012112796 <1012112796@qq.com>
web_src/js/features/repo-diff-filetree.ts
web_src/js/features/repo-diff.ts

index 6d9533d0669f0c200722b140d05fc6803d7145d4..bc275a90f6ab30a9a0dc3846ce03a553ffc68297 100644 (file)
@@ -8,7 +8,9 @@ export function initDiffFileTree() {
 
   const fileTreeView = createApp(DiffFileTree);
   fileTreeView.mount(el);
+}
 
+export function initDiffFileList() {
   const fileListElement = document.querySelector('#diff-file-list');
   if (!fileListElement) return;
 
index 5d6388a43e1d833e7a6ed4a58b675b05c67e8119..a0bd9955fe4689bf13beb39176d78c114a2fdcf3 100644 (file)
@@ -1,7 +1,7 @@
 import $ from 'jquery';
 import {initCompReactionSelector} from './comp/ReactionSelector.ts';
 import {initRepoIssueContentHistory} from './repo-issue-content.ts';
-import {initDiffFileTree} from './repo-diff-filetree.ts';
+import {initDiffFileTree, initDiffFileList} from './repo-diff-filetree.ts';
 import {initDiffCommitSelect} from './repo-diff-commitselect.ts';
 import {validateTextareaNonEmpty} from './comp/ComboMarkdownEditor.ts';
 import {initViewedCheckboxListenerFor, countAndUpdateViewedFiles, initExpandAndCollapseFilesButton} from './pull-view-file.ts';
@@ -216,6 +216,7 @@ export function initRepoDiffView() {
   initRepoDiffConversationForm();
   if (!$('#diff-file-list').length) return;
   initDiffFileTree();
+  initDiffFileList();
   initDiffCommitSelect();
   initRepoDiffShowMore();
   initRepoDiffReviewButton();