From 9b95991fac8ce054449077f40edc8c771f13a85f Mon Sep 17 00:00:00 2001 From: Chivorotkiv Date: Thu, 14 Nov 2024 15:23:25 +0100 Subject: [PATCH] In Start Work switches to issue list before waiting for the result (#3741, #3751) --- src/plus/startWork/startWork.ts | 48 ++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/src/plus/startWork/startWork.ts b/src/plus/startWork/startWork.ts index f2c408bbed775..732ef76d5fd11 100644 --- a/src/plus/startWork/startWork.ts +++ b/src/plus/startWork/startWork.ts @@ -161,22 +161,8 @@ export class StartWorkCommand extends QuickCommand { } } - await updateContextItems(this.container, context); - if (this.container.telemetry.enabled) { - this.container.telemetry.sendEvent( - opened ? 'startWork/steps/issue' : 'startWork/opened', - { - ...context.telemetryContext!, - connected: true, - type: state.type, - }, - this.source, - ); - } - + const result = yield* this.pickIssueStep(state, context, opened); opened = true; - - const result = yield* this.pickIssueStep(state, context); if (result === StepResultBreak) continue; if (!isStartWorkTypeItem(result)) { state.item = result; @@ -420,6 +406,7 @@ export class StartWorkCommand extends QuickCommand { private *pickIssueStep( state: StepState, context: Context, + opened: boolean, ): StepResultGenerator { const buildIssueItem = (i: StartWorkItem) => { const buttons = i.item.issue.url ? [OpenOnGitHubQuickInputButton] : []; @@ -470,14 +457,37 @@ export class StartWorkCommand extends QuickCommand { }; } - const { items, placeholder } = getItemsAndPlaceholder(); + const updateItems = async (quickpick: QuickPick) => { + quickpick.busy = true; + try { + await updateContextItems(this.container, context); + const { items, placeholder } = getItemsAndPlaceholder(); + quickpick.placeholder = placeholder; + quickpick.items = items; + + if (this.container.telemetry.enabled) { + this.container.telemetry.sendEvent( + opened ? 'startWork/steps/issue' : 'startWork/opened', + { + ...context.telemetryContext!, + connected: true, + type: state.type, + }, + this.source, + ); + } + } finally { + quickpick.busy = false; + } + }; - const step = createPickStep<(typeof items)[0]>({ + const step = createPickStep>({ title: context.title, - placeholder: placeholder, + placeholder: 'Loading...', matchOnDescription: true, matchOnDetail: true, - items: items, + items: [], + onDidActivate: updateItems, onDidClickItemButton: (_quickpick, button, { item }) => { if (button === OpenOnGitHubQuickInputButton && !isStartWorkTypeItem(item)) { this.open(item);