Added shortcut sub icon

This commit is contained in:
Dustin Brett
2021-09-25 23:14:40 -07:00
parent ce8ba625d5
commit a843c78837
6 changed files with 21 additions and 9 deletions

View File

@@ -121,22 +121,26 @@ export const getInfoWithExtension = (
extension: string,
callback: (value: FileInfo) => void
): void => {
const subIcons: string[] = [];
const getInfoByFileExtension = (icon?: string): void =>
callback({
icon: icon || getIconByFileExtension(extension),
pid: getProcessByFileExtension(extension),
subIcons,
url: path,
});
if (extension === SHORTCUT_EXTENSION) {
fs.readFile(path, (error, contents = EMPTY_BUFFER) => {
subIcons.push("/System/Icons/shortcut.png");
if (error) {
getInfoByFileExtension();
} else {
const { icon, pid, url } = getShortcutInfo(contents);
const urlExt = extname(url);
callback({ icon, pid, url });
callback({ icon, pid, subIcons, url });
if (
IMAGE_FILE_EXTENSIONS.has(urlExt) ||
@@ -145,7 +149,7 @@ export const getInfoWithExtension = (
) {
getInfoWithExtension(fs, url, urlExt, ({ icon: urlIcon }) => {
if (urlIcon && urlIcon !== icon) {
callback({ icon: urlIcon, pid, url });
callback({ icon: urlIcon, pid, subIcons, url });
}
});
}

View File

@@ -62,7 +62,7 @@ const FileEntry = ({
view,
}: FileEntryProps): JSX.Element => {
const { blurEntry, focusEntry } = focusFunctions;
const { icon, pid, url } = useFileInfo(path, stats.isDirectory());
const { icon, pid, subIcons, url } = useFileInfo(path, stats.isDirectory());
const openFile = useFile(url);
const { pasteList } = useFileSystem();
const { formats } = useTheme();
@@ -156,12 +156,15 @@ const FileEntry = ({
)}
>
<figure>
<Icon
src={icon}
alt={name}
moving={pasteList[path] === "move"}
{...FileEntryIconSize[view]}
/>
{[icon, ...(subIcons || [])].map((entryIcon) => (
<Icon
key={entryIcon}
src={entryIcon}
alt={name}
moving={icon === entryIcon && pasteList[path] === "move"}
{...FileEntryIconSize[view]}
/>
))}
{renaming ? (
<RenameBox
name={name}

View File

@@ -8,6 +8,7 @@ import { useEffect, useState } from "react";
export type FileInfo = {
icon: string;
subIcons?: string[];
pid: string;
url: string;
};

View File

@@ -44,6 +44,10 @@ const StyledFileEntry = styled.li<StyledFileEntryProps>`
img {
width: ${({ theme }) => theme.sizes.fileEntry.iconSize};
&:not(:first-of-type) {
position: absolute;
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B