Skip to content

Commit d480ac1

Browse files
gcomnenoderibaucourt
authored andcommitted
refactor: simplify BitBake config picker flow
1 parent 30c7a0c commit d480ac1

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

client/src/ui/BitbakeConfigPicker.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,23 @@ export class BitbakeConfigPicker {
5858
}
5959

6060
public async pickConfiguration (name?: string): Promise<void> {
61-
if (this.bitbakeSettings?.buildConfigurations !== undefined && this.bitbakeSettings?.buildConfigurations?.length > 0) {
62-
if (name !== undefined && this.bitbakeSettings.buildConfigurations.find((config) => config.name === name) !== undefined) {
63-
this.activeBuildConfiguration = name
64-
this.updateStatusBar(this.bitbakeSettings)
65-
} else {
66-
const options = this.bitbakeSettings.buildConfigurations.map((config) => config.name)
67-
const filteredOptions = options.filter((option) => typeof option === 'string') as string[] // Always all according to the definition in client/package.json
68-
const selection = await vscode.window.showQuickPick(filteredOptions, { placeHolder: 'Select a BitBake configuration' })
69-
if (selection !== undefined) {
70-
this.activeBuildConfiguration = selection
71-
this.updateStatusBar(this.bitbakeSettings)
72-
}
73-
}
61+
const buildConfigurations = this.bitbakeSettings?.buildConfigurations
62+
if (buildConfigurations === undefined || buildConfigurations.length === 0) {
63+
return
64+
}
65+
66+
let selection = name
67+
if (selection === undefined || buildConfigurations.find((config) => config.name === selection) === undefined) {
68+
const options = buildConfigurations.map((config) => config.name)
69+
const filteredOptions = options.filter((option) => typeof option === 'string') as string[] // Always all according to the definition in client/package.json
70+
selection = await vscode.window.showQuickPick(filteredOptions, { placeHolder: 'Select a BitBake configuration' })
7471
}
72+
73+
if (selection === undefined) {
74+
return
75+
}
76+
77+
this.activeBuildConfiguration = selection
78+
this.updateStatusBar(this.bitbakeSettings)
7579
}
7680
}

0 commit comments

Comments
 (0)