Skip to content

Commit

Permalink
fix: overwriting individual color with global color
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWoelki committed Jan 6, 2024
1 parent 88e16f7 commit db0304b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
7 changes: 7 additions & 0 deletions src/lib/util/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ const refreshIconNodes = (
'.iconize-icon',
) as HTMLElement | null;
if (iconNode) {
const pathValue = plugin.getData()[path];
const hasIndividualColor =
typeof pathValue === 'object' && pathValue.iconColor;
if (hasIndividualColor) {
return;
}

iconNode.innerHTML = applyStyles(
plugin,
iconNode.innerHTML,
Expand Down
24 changes: 8 additions & 16 deletions src/settings/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,17 @@ const refreshStyleOfIcons = async (plugin: IconFolderPlugin): Promise<void> => {
for (const fileExplorer of fileExplorers) {
// Refreshes the icon style for all inheritance folders.
for (const folderPath of Object.keys(inheritance.getFolders(plugin))) {
// Apply style for the icon node itself.
const folderItem = fileExplorer.view.fileItems[folderPath];
if (folderItem) {
const titleEl = getFileItemTitleEl(folderItem);
const iconNode = titleEl.querySelector(
'.iconize-icon',
) as HTMLElement | null;
if (iconNode) {
iconNode.innerHTML = style.applyAll(
plugin,
iconNode.innerHTML,
iconNode,
);
}
}

// Apply style for all files in this inheritance.
const files = inheritance.getFiles(plugin, folderPath);
for (const file of files) {
const filePathValue = plugin.getData()[file.path];
if (
filePathValue ||
(typeof filePathValue === 'object' && filePathValue.iconColor)
) {
continue;
}

const fileItem = fileExplorer.view.fileItems[file.path];
const titleEl = getFileItemTitleEl(fileItem);
const iconNode = titleEl.querySelector(
Expand Down

0 comments on commit db0304b

Please sign in to comment.