Skip to content

Commit

Permalink
refactor(vscode): move get participant id logic as fn
Browse files Browse the repository at this point in the history
  • Loading branch information
nedpals committed Mar 20, 2024
1 parent 81cc71c commit 8ff269e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions vscode-bugbuddy/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,8 @@ export async function startServer() {
await client.start();

// get participant id
try {
// eslint-disable-next-line @typescript-eslint/naming-convention
const got = await client.sendRequest<{ participant_id: string }>('$/participantId');
setConnectionStatus(ConnectionStatus.connected, { participantId: got.participant_id });
} catch (e) {
setConnectionStatus(ConnectionStatus.connected, { participantId: 'unknown' });
}
const participantId = await getParticipantId();
setConnectionStatus(ConnectionStatus.connected, { participantId });
} catch (e) {
setConnectionStatus(ConnectionStatus.failed);
window.showErrorMessage(`Failed to connect: ${e}`);
Expand Down Expand Up @@ -231,6 +226,15 @@ export async function showServerMenu() {
}
}

export async function getParticipantId() {
try {
const got = await client.sendRequest<{ participant_id: string }>('$/participantId');
return got.participant_id;
} catch (e) {
return 'unknown';
}
}

export async function generateParticipantId() {
const resp = await window.showInformationMessage('Are you sure you want to generate a new participant ID?', 'Yes', 'No');

Expand Down

0 comments on commit 8ff269e

Please sign in to comment.