Skip to content

Commit

Permalink
Fix macro choice selected macro display
Browse files Browse the repository at this point in the history
  • Loading branch information
chhoumann committed Jun 20, 2021
1 parent c8aa13b commit a718927
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "quickadd",
"name": "QuickAdd",
"version": "0.1.14",
"version": "0.1.15",
"minAppVersion": "0.12.00",
"description": "Quickly add new pages or content to your vault.",
"author": "Christian B. B. Houmann",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quickadd",
"version": "0.1.14",
"version": "0.1.15",
"description": "Quickly add new pages or content to your vault.",
"main": "main.js",
"scripts": {
Expand Down
19 changes: 10 additions & 9 deletions src/gui/ChoiceBuilder/macroChoiceBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import type {IMacro} from "../../types/macros/IMacro";
export class MacroChoiceBuilder extends ChoiceBuilder {
choice: IMacroChoice;
selectedMacro: IMacro;
private updateSelectedMacro: (macro: IMacro) => void;
private updateSelectedMacro: () => void;

constructor(app: App, choice: IMacroChoice, private macros: IMacro[]) {
super(app);
this.choice = choice;
this.selectedMacro = this.macros.find(m => m.id === this.choice.macroId);

this.display();
}
Expand All @@ -25,15 +24,17 @@ export class MacroChoiceBuilder extends ChoiceBuilder {
}

private addSelectedMacroElement() {
const selectedMacro = this.contentEl.createEl('h3');
selectedMacro.style.textAlign = "center";
const selectedMacroEl = this.contentEl.createEl('h3');
selectedMacroEl.style.textAlign = "center";

this.updateSelectedMacro = (macro => {
if (macro)
selectedMacro.textContent = `Selected macro: ${macro.name}`;
this.updateSelectedMacro = (() => {
this.selectedMacro = this.macros.find(m => m.id === this.choice.macroId);

if (this.selectedMacro)
selectedMacroEl.textContent = `Selected macro: ${this.selectedMacro.name}`;
});

this.updateSelectedMacro(this.choice.macro);
this.updateSelectedMacro();
}

private addSelectMacroSearch() {
Expand All @@ -50,7 +51,7 @@ export class MacroChoiceBuilder extends ChoiceBuilder {
if (!macro) return;

this.choice.macroId = macro.id;
this.updateSelectedMacro(this.choice.macro);
this.updateSelectedMacro();

searchComponent.setValue("");
}
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"0.1.14": "0.12.4"
"0.1.15": "0.12.4"
}

0 comments on commit a718927

Please sign in to comment.