Skip to content

Commit 028264f

Browse files
committed
Fix some Properties icon issues
1 parent 4cc7d49 commit 028264f

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

components/system/Dialogs/Properties/GeneralTab.tsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { memo, useEffect, useMemo, useRef, useState } from "react";
33
import Buttons from "components/system/Dialogs/Properties/Buttons";
44
import useStats from "components/system/Dialogs/Properties/useStats";
55
import 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";
710
import {
811
type FileStat,
912
removeInvalidFilenameCharacters,
@@ -13,7 +16,12 @@ import { useProcesses } from "contexts/process";
1316
import directory from "contexts/process/directory";
1417
import { useSession } from "contexts/session";
1518
import 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";
1725
import { getExtension, getFormattedSize } from "utils/functions";
1826

1927
type TabProps = {
@@ -33,13 +41,13 @@ const dateTimeString = (date?: Date): string =>
3341
.replace(" at ", ", ") || "";
3442

3543
const 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>

components/system/Dialogs/Properties/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ const Properties: FC<ComponentProcessProps> = ({ id }) => {
4949
useEffect(() => {
5050
setIcon(id, icon);
5151

52-
if (typeof getIcon === "function") {
52+
const extension = extname(generalUrl);
53+
54+
if (typeof getIcon === "function" && extension.toLowerCase() === ".exe") {
5355
getIconAbortController.current = new AbortController();
5456
getIcon(getIconAbortController.current.signal);
5557
}
5658

5759
if (generalUrl) {
5860
prependFileToTitle(
59-
basename(generalUrl, shortcutPath ? extname(generalUrl) : undefined),
61+
basename(generalUrl, shortcutPath ? extension : undefined),
6062
false,
6163
true
6264
);

0 commit comments

Comments
 (0)