@@ -3,7 +3,10 @@ import { memo, useEffect, useMemo, useRef, useState } from "react";
33import Buttons from "components/system/Dialogs/Properties/Buttons" ;
44import useStats from "components/system/Dialogs/Properties/useStats" ;
55import extensions from "components/system/Files/FileEntry/extensions" ;
6- import { getModifiedTime } from "components/system/Files/FileEntry/functions" ;
6+ import {
7+ getIconFromIni ,
8+ getModifiedTime ,
9+ } from "components/system/Files/FileEntry/functions" ;
710import {
811 type FileStat ,
912 removeInvalidFilenameCharacters ,
@@ -13,7 +16,12 @@ import { useProcesses } from "contexts/process";
1316import directory from "contexts/process/directory" ;
1417import { useSession } from "contexts/session" ;
1518import Icon from "styles/common/Icon" ;
16- import { DEFAULT_LOCALE , DESKTOP_PATH , SHORTCUT_ICON } from "utils/constants" ;
19+ import {
20+ DEFAULT_LOCALE ,
21+ DESKTOP_PATH ,
22+ FOLDER_ICON ,
23+ SHORTCUT_ICON ,
24+ } from "utils/constants" ;
1725import { getExtension , getFormattedSize } from "utils/functions" ;
1826
1927type TabProps = {
@@ -33,13 +41,13 @@ const dateTimeString = (date?: Date): string =>
3341 . replace ( " at " , ", " ) || "" ;
3442
3543const GeneralTab : FC < TabProps > = ( { icon, id, isShortcut, pid, url } ) => {
36- const { closeWithTransition } = useProcesses ( ) ;
44+ const { closeWithTransition, icon : setIcon } = useProcesses ( ) ;
3745 const { setIconPositions } = useSession ( ) ;
3846 const extension = useMemo ( ( ) => getExtension ( url || "" ) , [ url ] ) ;
3947 const { type } = extensions [ extension ] || { } ;
4048 const extType = type || `${ extension . toUpperCase ( ) . replace ( "." , "" ) } File` ;
4149 const inputRef = useRef < HTMLInputElement > ( null ) ;
42- const { readdir, rename, stat, updateFolder } = useFileSystem ( ) ;
50+ const { fs , readdir, rename, stat, updateFolder } = useFileSystem ( ) ;
4351 const stats = useStats ( url ) ;
4452 const [ fileCount , setFileCount ] = useState ( 0 ) ;
4553 const [ folderCount , setFolderCount ] = useState ( 0 ) ;
@@ -48,6 +56,19 @@ const GeneralTab: FC<TabProps> = ({ icon, id, isShortcut, pid, url }) => {
4856 const entrySize = folderSize || ( isDirectory ? 0 : stats ?. size ) ;
4957 const checkedFileCounts = useRef ( false ) ;
5058 const abortControllerRef = useRef < AbortController > ( ) ;
59+ const [ folderIcon , setFolderIcon ] = useState ( FOLDER_ICON ) ;
60+
61+ useEffect ( ( ) => {
62+ if ( isDirectory && fs ) {
63+ if ( folderIcon === FOLDER_ICON ) {
64+ getIconFromIni ( fs , url ) . then (
65+ ( iconFile ) => iconFile && setFolderIcon ( iconFile )
66+ ) ;
67+ }
68+
69+ setIcon ( id , folderIcon || FOLDER_ICON ) ;
70+ }
71+ } , [ folderIcon , fs , id , isDirectory , setIcon , url ] ) ;
5172
5273 useEffect ( ( ) => {
5374 if ( ! checkedFileCounts . current && ! isShortcut && isDirectory ) {
@@ -93,7 +114,7 @@ const GeneralTab: FC<TabProps> = ({ icon, id, isShortcut, pid, url }) => {
93114 < tbody >
94115 < tr className = "header" >
95116 < th scope = "row" >
96- < Icon imgSize = { 32 } src = { icon } />
117+ < Icon imgSize = { 32 } src = { isDirectory ? folderIcon : icon } />
97118 { isShortcut && < Icon imgSize = { 48 } src = { SHORTCUT_ICON } /> }
98119 </ th >
99120 < td >
0 commit comments