mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 02:46:04 +01:00 
			
		
		
		
	Mark parent directory as viewed when all files are viewed (#33958)
Fix #25644 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -1,21 +1,14 @@ | ||||
| <script lang="ts" setup> | ||||
| import DiffFileTreeItem from './DiffFileTreeItem.vue'; | ||||
| import {toggleElem} from '../utils/dom.ts'; | ||||
| import {diffTreeStore} from '../modules/stores.ts'; | ||||
| import {diffTreeStore} from '../modules/diff-file.ts'; | ||||
| import {setFileFolding} from '../features/file-fold.ts'; | ||||
| import {computed, onMounted, onUnmounted} from 'vue'; | ||||
| import {pathListToTree, mergeChildIfOnlyOneDir} from '../utils/filetree.ts'; | ||||
| import {onMounted, onUnmounted} from 'vue'; | ||||
|  | ||||
| const LOCAL_STORAGE_KEY = 'diff_file_tree_visible'; | ||||
|  | ||||
| const store = diffTreeStore(); | ||||
|  | ||||
| const fileTree = computed(() => { | ||||
|   const result = pathListToTree(store.files); | ||||
|   mergeChildIfOnlyOneDir(result); // mutation | ||||
|   return result; | ||||
| }); | ||||
|  | ||||
| onMounted(() => { | ||||
|   // Default to true if unset | ||||
|   store.fileTreeIsVisible = localStorage.getItem(LOCAL_STORAGE_KEY) !== 'false'; | ||||
| @@ -50,7 +43,7 @@ function toggleVisibility() { | ||||
|  | ||||
| function updateVisibility(visible: boolean) { | ||||
|   store.fileTreeIsVisible = visible; | ||||
|   localStorage.setItem(LOCAL_STORAGE_KEY, store.fileTreeIsVisible); | ||||
|   localStorage.setItem(LOCAL_STORAGE_KEY, store.fileTreeIsVisible.toString()); | ||||
|   updateState(store.fileTreeIsVisible); | ||||
| } | ||||
|  | ||||
| @@ -69,7 +62,7 @@ function updateState(visible: boolean) { | ||||
| <template> | ||||
|   <div v-if="store.fileTreeIsVisible" class="diff-file-tree-items"> | ||||
|     <!-- only render the tree if we're visible. in many cases this is something that doesn't change very often --> | ||||
|     <DiffFileTreeItem v-for="item in fileTree" :key="item.name" :item="item"/> | ||||
|     <DiffFileTreeItem v-for="item in store.diffFileTree.TreeRoot.Children" :key="item.FullName" :item="item"/> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user