menu.placeTag

This commit is contained in:
Jan Prochazka
2021-04-08 06:55:14 +02:00
parent bcc1f91352
commit 2db17f9eca
4 changed files with 76 additions and 53 deletions

View File

@@ -31,13 +31,19 @@ export interface GlobalCommand {
export default function registerCommand(command: GlobalCommand) {
const { testEnabled } = command;
commands.update(x => ({
...x,
[command.id]: {
text: `${command.category}: ${command.name}`,
...command,
enabled: !testEnabled,
},
}));
commands.update(x => {
if (x[command.id]) {
console.error(`Command ${command.id} already registered`);
return x;
}
return {
...x,
[command.id]: {
text: `${command.category}: ${command.name}`,
...command,
enabled: !testEnabled,
},
};
});
invalidateCommandDefinitions();
}