Skip to content

Commit

Permalink
Fix select macro bug for users with 0-1 macros
Browse files Browse the repository at this point in the history
  • Loading branch information
chhoumann committed Jun 24, 2021
1 parent 76d4af3 commit 7179e77
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 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.2.9",
"version": "0.2.10",
"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.2.9",
"version": "0.2.10",
"description": "Quickly add new pages or content to your vault.",
"main": "main.js",
"scripts": {
Expand Down
23 changes: 18 additions & 5 deletions src/gui/ChoiceBuilder/macroChoiceBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,26 @@ export class MacroChoiceBuilder extends ChoiceBuilder {

dropdown.addOptions(macroOptions);
dropdown.onChange(value => {
const targetMacro: IMacro = this.macros.find(m => m.name === value);
if (!targetMacro) return;

this.choice.macroId = targetMacro.id;
this.selectMacro(value);
});

console.log(dropdown.getValue());

const selectedMacro: IMacro = this.macros.find(m => m.id === this.choice.macroId);
if (selectedMacro) dropdown.setValue(selectedMacro.name);
if (selectedMacro) {
dropdown.setValue(selectedMacro.name);
} else {
const value = dropdown.getValue();
if (value) {
this.selectMacro(value);
}
}
}

private selectMacro(value: string) {
const targetMacro: IMacro = this.macros.find(m => m.name === value);
if (!targetMacro) return;

this.choice.macroId = targetMacro.id;
}
}
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"0.2.9": "0.12.4"
"0.2.10": "0.12.4"
}

0 comments on commit 7179e77

Please sign in to comment.