Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions src/plus/startWork/startWork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,8 @@ export class StartWorkCommand extends QuickCommand<State> {
}
}

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;
Expand Down Expand Up @@ -420,6 +406,7 @@ export class StartWorkCommand extends QuickCommand<State> {
private *pickIssueStep(
state: StepState<State>,
context: Context,
opened: boolean,
): StepResultGenerator<StartWorkItem | StartWorkTypeItem> {
const buildIssueItem = (i: StartWorkItem) => {
const buttons = i.item.issue.url ? [OpenOnGitHubQuickInputButton] : [];
Expand Down Expand Up @@ -470,14 +457,37 @@ export class StartWorkCommand extends QuickCommand<State> {
};
}

const { items, placeholder } = getItemsAndPlaceholder();
const updateItems = async (quickpick: QuickPick<any>) => {
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<QuickPickItemOfT<StartWorkItem | StartWorkTypeItem>>({
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);
Expand Down
Loading