mirror of
https://github.com/jsmorabito/obsidian-commander.git
synced 2026-07-22 06:40:31 +00:00
fix: macro icons now display correctly in all UI contexts
Set icon directly on addCommand so it appears in the command palette, status bar, and mobile toolbar. Also fixes removeCommand referencing bare `app` instead of `plugin.app`, and replaces Array.remove() during forEach iteration (mutation hazard) with a filter in injectIcons. Fixes #149 (cherry-picked from PR by Anton/Lyqed) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
13c5c1e1b2
commit
b4ae810c84
1 changed files with 5 additions and 4 deletions
|
|
@ -144,16 +144,17 @@ export function updateMacroCommands(plugin: CommanderPlugin): void {
|
|||
);
|
||||
for (const command of oldCommands) {
|
||||
//@ts-ignore
|
||||
app.commands.removeCommand(command);
|
||||
plugin.app.commands.removeCommand(command);
|
||||
}
|
||||
|
||||
const macros = plugin.settings.macros;
|
||||
for (const [idx, macro] of Object.entries(macros)) {
|
||||
for (const [idx, macro] of macros.entries()) {
|
||||
plugin.addCommand({
|
||||
id: `macro-${idx}`,
|
||||
name: macro.name,
|
||||
icon: macro.icon,
|
||||
callback: () => {
|
||||
plugin.executeMacro(parseInt(idx));
|
||||
plugin.executeMacro(Number(idx));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -195,7 +196,7 @@ export function injectIcons(
|
|||
if (command) {
|
||||
command.icon = mapped.iconID;
|
||||
} else {
|
||||
settings.mappedIcons.remove(mapped);
|
||||
settings.mappedIcons = settings.mappedIcons.filter(m => m !== mapped);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue