1
1
<script lang="ts" setup>
2
2
import {SvgIcon , type SvgName } from ' ../svg.ts' ;
3
3
import {diffTreeStore } from ' ../modules/stores.ts' ;
4
- import {ref } from ' vue' ;
4
+ import {computed , ref } from ' vue' ;
5
+ import {fileIsViewed } from ' ../utils/filetree.ts' ;
5
6
import type {Item , File , FileStatus } from ' ../utils/filetree.ts' ;
6
7
7
- defineProps <{
8
+ const props = defineProps <{
8
9
item: Item ,
9
10
}>();
10
11
11
12
const store = diffTreeStore ();
12
- const collapsed = ref (false );
13
+ const isViewed = computed (() => {
14
+ return fileIsViewed (props .item );
15
+ });
16
+ const collapsed = ref (isViewed .value );
13
17
14
18
function getIconForDiffStatus(pType : FileStatus ) {
15
19
const diffTypes: Record <FileStatus , { name: SvgName , classes: Array <string > }> = {
@@ -35,7 +39,7 @@ function fileIcon(file: File) {
35
39
<!-- 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"-->
36
40
<a
37
41
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 }"
39
43
:title =" item.name" :href =" '#diff-' + item.file.NameHash"
40
44
>
41
45
<!-- file -->
@@ -48,7 +52,7 @@ function fileIcon(file: File) {
48
52
</a >
49
53
50
54
<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" >
52
56
<!-- directory -->
53
57
<SvgIcon :name =" collapsed ? 'octicon-chevron-right' : 'octicon-chevron-down'" />
54
58
<SvgIcon
@@ -88,7 +92,8 @@ a:hover {
88
92
border-radius : 4px ;
89
93
}
90
94
91
- .item-file.viewed {
95
+ .item-file.viewed ,
96
+ .item-directory.viewed {
92
97
color : var (--color-text-light-3 );
93
98
}
94
99
0 commit comments