Skip to content

Commit 7e85b17

Browse files
authored
Fixes duplication of imported custom icons (#621)
1 parent ceb8efa commit 7e85b17

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

src/icon-pack-manager.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -508,15 +508,17 @@ export const initIconPacks = async (plugin: IconizePlugin): Promise<void> => {
508508
}
509509

510510
const prefix = createIconPackPrefix(folderName);
511-
iconPacks.push({
512-
name: folderName,
513-
icons: loadedIcons,
514-
prefix,
515-
custom: true,
516-
});
517-
logger.info(
518-
`Loaded icon pack '${folderName}' (amount of icons: ${loadedIcons.length})`,
519-
);
511+
if (!iconPacks.some(iconPack => iconPack.name === folderName)) {
512+
iconPacks.push({
513+
name: folderName,
514+
icons: loadedIcons,
515+
prefix,
516+
custom: true,
517+
});
518+
logger.info(
519+
`Loaded icon pack '${folderName}' (amount of icons: ${loadedIcons.length})`,
520+
);
521+
}
520522
}
521523

522524
// Extract all files from the zip files.
@@ -531,15 +533,17 @@ export const initIconPacks = async (plugin: IconizePlugin): Promise<void> => {
531533
continue;
532534
}
533535

534-
iconPacks.push({
535-
name: zipFile,
536-
icons: loadedIcons,
537-
prefix,
538-
custom: false,
539-
});
540-
logger.info(
541-
`Loaded icon pack '${zipFile}' (amount of icons: ${loadedIcons.length})`,
542-
);
536+
if (!iconPacks.some(iconPack => iconPack.name === zipFile)) {
537+
iconPacks.push({
538+
name: zipFile,
539+
icons: loadedIcons,
540+
prefix,
541+
custom: false,
542+
});
543+
logger.info(
544+
`Loaded icon pack '${zipFile}' (amount of icons: ${loadedIcons.length})`,
545+
);
546+
}
543547
}
544548
};
545549

0 commit comments

Comments
 (0)