Skip to content

Commit 2078a99

Browse files
In Start Work switches to issue list before waiting for the result (#3751)
(#3741, #3751) Co-authored-by: Chivorotkiv <[email protected]>
1 parent d11fa99 commit 2078a99

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

src/plus/startWork/startWork.ts

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,8 @@ export class StartWorkCommand extends QuickCommand<State> {
166166
}
167167
}
168168

169-
await updateContextItems(this.container, context);
170-
if (this.container.telemetry.enabled) {
171-
this.container.telemetry.sendEvent(
172-
opened ? 'startWork/steps/issue' : 'startWork/opened',
173-
{
174-
...context.telemetryContext!,
175-
connected: true,
176-
type: state.type,
177-
},
178-
this.source,
179-
);
180-
}
181-
169+
const result = yield* this.pickIssueStep(state, context, opened);
182170
opened = true;
183-
184-
const result = yield* this.pickIssueStep(state, context);
185171
if (result === StepResultBreak) continue;
186172
if (!isStartWorkTypeItem(result)) {
187173
state.item = result;
@@ -425,6 +411,7 @@ export class StartWorkCommand extends QuickCommand<State> {
425411
private *pickIssueStep(
426412
state: StepState<State>,
427413
context: Context,
414+
opened: boolean,
428415
): StepResultGenerator<StartWorkItem | StartWorkTypeItem> {
429416
const buildIssueItem = (i: StartWorkItem) => {
430417
const buttons = i.item.issue.url ? [OpenOnGitHubQuickInputButton] : [];
@@ -475,14 +462,37 @@ export class StartWorkCommand extends QuickCommand<State> {
475462
};
476463
}
477464

478-
const { items, placeholder } = getItemsAndPlaceholder();
465+
const updateItems = async (quickpick: QuickPick<any>) => {
466+
quickpick.busy = true;
467+
try {
468+
await updateContextItems(this.container, context);
469+
const { items, placeholder } = getItemsAndPlaceholder();
470+
quickpick.placeholder = placeholder;
471+
quickpick.items = items;
472+
473+
if (this.container.telemetry.enabled) {
474+
this.container.telemetry.sendEvent(
475+
opened ? 'startWork/steps/issue' : 'startWork/opened',
476+
{
477+
...context.telemetryContext!,
478+
connected: true,
479+
type: state.type,
480+
},
481+
this.source,
482+
);
483+
}
484+
} finally {
485+
quickpick.busy = false;
486+
}
487+
};
479488

480-
const step = createPickStep<(typeof items)[0]>({
489+
const step = createPickStep<QuickPickItemOfT<StartWorkItem | StartWorkTypeItem>>({
481490
title: context.title,
482-
placeholder: placeholder,
491+
placeholder: 'Loading...',
483492
matchOnDescription: true,
484493
matchOnDetail: true,
485-
items: items,
494+
items: [],
495+
onDidActivate: updateItems,
486496
onDidClickItemButton: (_quickpick, button, { item }) => {
487497
if (button === OpenOnGitHubQuickInputButton && !isStartWorkTypeItem(item)) {
488498
this.open(item);

0 commit comments

Comments
 (0)