11<script lang="ts" setup>
22import {SvgIcon , type SvgName } from ' ../svg.ts' ;
33import {diffTreeStore } from ' ../modules/stores.ts' ;
4- import {ref } from ' vue' ;
4+ import {computed , ref } from ' vue' ;
5+ import {fileIsViewed } from ' ../utils/filetree.ts' ;
56import type {Item , File , FileStatus } from ' ../utils/filetree.ts' ;
67
7- defineProps <{
8+ const props = defineProps <{
89 item: Item ,
910}>();
1011
1112const store = diffTreeStore ();
12- const collapsed = ref (false );
13+ const isViewed = computed (() => {
14+ return fileIsViewed (props .item );
15+ });
16+ const collapsed = ref (isViewed .value );
1317
1418function getIconForDiffStatus(pType : FileStatus ) {
1519 const diffTypes: Record <FileStatus , { name: SvgName , classes: Array <string > }> = {
@@ -35,7 +39,7 @@ function fileIcon(file: File) {
3539 <!-- title instead of tooltip above as the tooltip needs too much work with the current methods, i.e. not being loaded or staying open for "too long"-->
3640 <a
3741 v-if =" item.isFile" class =" item-file"
38- :class =" { 'selected': store.selectedItem === '#diff-' + item.file.NameHash, 'viewed': item.file.IsViewed }"
42+ :class =" { 'selected': store.selectedItem === '#diff-' + item.file.NameHash, 'viewed': isViewed }"
3943 :title =" item.name" :href =" '#diff-' + item.file.NameHash"
4044 >
4145 <!-- file -->
@@ -48,7 +52,7 @@ function fileIcon(file: File) {
4852 </a >
4953
5054 <template v-else-if =" item .isFile === false " >
51- <div class =" item-directory" :title =" item.name" @click.stop =" collapsed = !collapsed" >
55+ <div class =" item-directory" :class = " { 'viewed': isViewed } " : title =" item.name" @click.stop =" collapsed = !collapsed" >
5256 <!-- directory -->
5357 <SvgIcon :name =" collapsed ? 'octicon-chevron-right' : 'octicon-chevron-down'" />
5458 <SvgIcon
@@ -88,7 +92,8 @@ a:hover {
8892 border-radius : 4px ;
8993}
9094
91- .item-file.viewed {
95+ .item-file.viewed ,
96+ .item-directory.viewed {
9297 color : var (--color-text-light-3 );
9398}
9499
0 commit comments