(choice: IChoice)
| 488 | } |
| 489 | |
| 490 | public addCommandForChoice(choice: IChoice) { |
| 491 | if (choice.type === "Multi") { |
| 492 | this.addCommandsForChoices((<IMultiChoice>choice).choices); |
| 493 | } |
| 494 | |
| 495 | if (choice.command) { |
| 496 | const choiceId = choice.id; |
| 497 | |
| 498 | this.addCommand({ |
| 499 | id: `choice:${choiceId}`, |
| 500 | name: choice.name, |
| 501 | icon: resolveChoiceIcon(choice), |
| 502 | callback: async () => { |
| 503 | try { |
| 504 | const current = this.getChoiceById(choiceId); |
| 505 | await new ChoiceExecutor(this.app, this).execute(current); |
| 506 | } catch (err) { |
| 507 | reportError(err, `Error executing choice ${choiceId}`); |
| 508 | } |
| 509 | }, |
| 510 | }); |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | public getChoiceById(choiceId: string): IChoice { |
| 515 | const choice = this.getChoice("id", choiceId); |
no test coverage detected