fix: correct badge item detection by checking classname prefix
Badge item_names already start with 'badge_' (e.g. badge_citycpa3),
so checking for badge_<item_name>_icon.png produces a double prefix
(badge_badge_citycpa3_icon.png). Now uses item_name.startsWith('badge_')
instead, which correctly identifies badge items without depending on
icon files existing in the directory.
This commit is contained in:
1 parent
1167a48344
commit
750973de38
3 files changed
+10
-11
No files matched your search
@@ -159,13 +159,11 @@ export async function repairMissingIcons(
|
||||
|
||||
const processItem = async (classname: string) => {
|
||||
const fileName = `${classname}_icon.png`;
|
||||
const badgeFileName = `badge_${classname}_icon.png`;
|
||||
|
||||
// Badge items store icons as badge_<code>_icon.png, not <code>_icon.png.
|
||||
const presentDirs = iconDirs.filter(
|
||||
(dir) =>
|
||||
existsSync(path.join(dir, fileName)) ||
|
||||
existsSync(path.join(dir, badgeFileName)),
|
||||
// Badge items store icons as badge_<code>_icon.png (the classname already
|
||||
// includes the `badge_` prefix, so fileName matches correctly).
|
||||
const presentDirs = iconDirs.filter((dir) =>
|
||||
existsSync(path.join(dir, fileName)),
|
||||
);
|
||||
const missingDirs = iconDirs.filter((dir) => !presentDirs.includes(dir));
|
||||
|
||||
@@ -239,7 +237,6 @@ export async function repairMissingIcons(
|
||||
for (const source of sources) {
|
||||
const iconCandidates = [
|
||||
`${classname}_icon.png`,
|
||||
`badge_${classname}_icon.png`,
|
||||
// Variant classnames (e.g. `table_silo_med*10`) often only exist
|
||||
// on sources under their base name (e.g. `table_silo_med_icon.png`)
|
||||
// or with the `*` replaced by `_` (e.g. `table_silo_med_10_icon.png`).
|
||||
|
||||
Reference in new issue
Block a user