Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e3dccd9

Browse files
committed
init
1 parent 19af64f commit e3dccd9

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/commands/session.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export async function getSessionList(): Promise<ISession[]> {
3333
}
3434

3535
export async function selectSession(): Promise<void> {
36-
const choice: IQuickItemEx<string> | undefined = await vscode.window.showQuickPick(parseSessionsToPicks());
36+
const choice: IQuickItemEx<string> | undefined = await vscode.window.showQuickPick(parseSessionsToPicks(true /* includeOperation */));
3737
if (!choice || choice.description === "Active") {
3838
return;
3939
}
40-
if (choice.value === ":createNewSession") {
40+
if (choice.value === ":createSession") {
4141
await vscode.commands.executeCommand("leetcode.createSession");
4242
return;
4343
}
@@ -50,7 +50,7 @@ export async function selectSession(): Promise<void> {
5050
}
5151
}
5252

53-
async function parseSessionsToPicks(): Promise<Array<IQuickItemEx<string>>> {
53+
async function parseSessionsToPicks(includeOperations: boolean = false): Promise<Array<IQuickItemEx<string>>> {
5454
return new Promise(async (resolve: (res: Array<IQuickItemEx<string>>) => void): Promise<void> => {
5555
try {
5656
const sessions: ISession[] = await getSessionList();
@@ -60,19 +60,31 @@ async function parseSessionsToPicks(): Promise<Array<IQuickItemEx<string>>> {
6060
detail: `AC Questions: ${s.acQuestions}, AC Submits: ${s.acSubmits}`,
6161
value: s.id,
6262
}));
63-
picks.push({
64-
label: "$(plus) Create a new session",
65-
description: "",
66-
detail: "Click this item to create a new session",
67-
value: ":createNewSession",
68-
});
63+
64+
if (includeOperations) {
65+
picks.push(...parseSessionManagementOperations());
66+
}
6967
resolve(picks);
7068
} catch (error) {
7169
return await promptForOpenOutputChannel("Failed to list sessions. Please open the output channel for details.", DialogType.error);
7270
}
7371
});
7472
}
7573

74+
function parseSessionManagementOperations(): Array<IQuickItemEx<string>> {
75+
return [{
76+
label: "$(plus) Create a session",
77+
description: "",
78+
detail: "Click this item to create a session",
79+
value: ":createSession",
80+
}, {
81+
label: "$(trashcan) Delete a session",
82+
description: "",
83+
detail: "Click this item to DELETE a session",
84+
value: ":deleteSession",
85+
}];
86+
}
87+
7688
export async function createSession(): Promise<void> {
7789
const session: string | undefined = await vscode.window.showInputBox({
7890
prompt: "Enter the new session name.",

0 commit comments

Comments
 (0)