Skip to content

Commit 146c377

Browse files
authored
Merge pull request #41 from ccagml/dev
update
2 parents d5ad3cd + fdecdf4 commit 146c377

File tree

1 file changed

+87
-86
lines changed

1 file changed

+87
-86
lines changed

src/commands/session.ts

Lines changed: 87 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// Copyright (c) jdneo. All rights reserved.
22
// Licensed under the MIT license.
33

4-
import * as vscode from "vscode";
4+
// import * as vscode from "vscode";
55
import { leetCodeExecutor } from "../leetCodeExecutor";
66
import { leetCodeManager } from "../leetCodeManager";
7-
import { IQuickItemEx } from "../shared";
8-
import { DialogOptions, DialogType, promptForOpenOutputChannel, promptForSignIn } from "../utils/uiUtils";
7+
// import { IQuickItemEx } from "../shared";
8+
// import { DialogOptions, DialogType, promptForOpenOutputChannel, promptForSignIn } from "../utils/uiUtils";
9+
import { promptForSignIn } from "../utils/uiUtils";
910

1011
export async function getSessionList(): Promise<ISession[]> {
1112
const signInStatus: string | undefined = leetCodeManager.getUser();
@@ -54,97 +55,97 @@ export async function manageSessions(): Promise<void> {
5455
// }
5556
}
5657

57-
async function parseSessionsToPicks(includeOperations: boolean = false): Promise<Array<IQuickItemEx<ISession | string>>> {
58-
return new Promise(async (resolve: (res: Array<IQuickItemEx<ISession | string>>) => void): Promise<void> => {
59-
try {
60-
const sessions: ISession[] = await getSessionList();
61-
const picks: Array<IQuickItemEx<ISession | string>> = sessions.map((s: ISession) => Object.assign({}, {
62-
label: `${s.active ? "$(check) " : ""}${s.name}`,
63-
description: s.active ? "Active" : "",
64-
detail: `AC Questions: ${s.acQuestions}, AC Submits: ${s.acSubmits}`,
65-
value: s,
66-
}));
58+
// async function parseSessionsToPicks(includeOperations: boolean = false): Promise<Array<IQuickItemEx<ISession | string>>> {
59+
// return new Promise(async (resolve: (res: Array<IQuickItemEx<ISession | string>>) => void): Promise<void> => {
60+
// try {
61+
// const sessions: ISession[] = await getSessionList();
62+
// const picks: Array<IQuickItemEx<ISession | string>> = sessions.map((s: ISession) => Object.assign({}, {
63+
// label: `${s.active ? "$(check) " : ""}${s.name}`,
64+
// description: s.active ? "Active" : "",
65+
// detail: `AC Questions: ${s.acQuestions}, AC Submits: ${s.acSubmits}`,
66+
// value: s,
67+
// }));
6768

68-
if (includeOperations) {
69-
picks.push(...parseSessionManagementOperations());
70-
}
71-
resolve(picks);
72-
} catch (error) {
73-
return await promptForOpenOutputChannel("Failed to list sessions. Please open the output channel for details.", DialogType.error);
74-
}
75-
});
76-
}
69+
// if (includeOperations) {
70+
// picks.push(...parseSessionManagementOperations());
71+
// }
72+
// resolve(picks);
73+
// } catch (error) {
74+
// return await promptForOpenOutputChannel("Failed to list sessions. Please open the output channel for details.", DialogType.error);
75+
// }
76+
// });
77+
// }
7778

78-
function parseSessionManagementOperations(): Array<IQuickItemEx<string>> {
79-
return [{
80-
label: "$(plus) Create a session",
81-
description: "",
82-
detail: "Click this item to create a session",
83-
value: ":createSession",
84-
}, {
85-
label: "$(trashcan) Delete a session",
86-
description: "",
87-
detail: "Click this item to DELETE a session",
88-
value: ":deleteSession",
89-
}];
90-
}
79+
// function parseSessionManagementOperations(): Array<IQuickItemEx<string>> {
80+
// return [{
81+
// label: "$(plus) Create a session",
82+
// description: "",
83+
// detail: "Click this item to create a session",
84+
// value: ":createSession",
85+
// }, {
86+
// label: "$(trashcan) Delete a session",
87+
// description: "",
88+
// detail: "Click this item to DELETE a session",
89+
// value: ":deleteSession",
90+
// }];
91+
// }
9192

92-
async function createSession(): Promise<void> {
93-
const session: string | undefined = await vscode.window.showInputBox({
94-
prompt: "Enter the new session name.",
95-
validateInput: (s: string): string | undefined => s && s.trim() ? undefined : "Session name must not be empty",
96-
});
97-
if (!session) {
98-
return;
99-
}
100-
try {
101-
await leetCodeExecutor.createSession(session);
102-
vscode.window.showInformationMessage("New session created, you can switch to it by clicking the status bar.");
103-
} catch (error) {
104-
await promptForOpenOutputChannel("Failed to create session. Please open the output channel for details.", DialogType.error);
105-
}
106-
}
93+
// async function createSession(): Promise<void> {
94+
// const session: string | undefined = await vscode.window.showInputBox({
95+
// prompt: "Enter the new session name.",
96+
// validateInput: (s: string): string | undefined => s && s.trim() ? undefined : "Session name must not be empty",
97+
// });
98+
// if (!session) {
99+
// return;
100+
// }
101+
// try {
102+
// await leetCodeExecutor.createSession(session);
103+
// vscode.window.showInformationMessage("New session created, you can switch to it by clicking the status bar.");
104+
// } catch (error) {
105+
// await promptForOpenOutputChannel("Failed to create session. Please open the output channel for details.", DialogType.error);
106+
// }
107+
// }
107108

108-
async function deleteSession(): Promise<void> {
109-
const choice: IQuickItemEx<ISession | string> | undefined = await vscode.window.showQuickPick(
110-
parseSessionsToPicks(false /* includeOperation */),
111-
{ placeHolder: "Please select the session you want to delete" },
112-
);
113-
if (!choice) {
114-
return;
115-
}
109+
// async function deleteSession(): Promise<void> {
110+
// const choice: IQuickItemEx<ISession | string> | undefined = await vscode.window.showQuickPick(
111+
// parseSessionsToPicks(false /* includeOperation */),
112+
// { placeHolder: "Please select the session you want to delete" },
113+
// );
114+
// if (!choice) {
115+
// return;
116+
// }
116117

117-
const selectedSession: ISession = choice.value as ISession;
118-
if (selectedSession.active) {
119-
vscode.window.showInformationMessage("Cannot delete an active session.");
120-
return;
121-
}
118+
// const selectedSession: ISession = choice.value as ISession;
119+
// if (selectedSession.active) {
120+
// vscode.window.showInformationMessage("Cannot delete an active session.");
121+
// return;
122+
// }
122123

123-
const action: vscode.MessageItem | undefined = await vscode.window.showWarningMessage(
124-
`This operation cannot be reverted. Are you sure to delete the session: ${selectedSession.name}?`,
125-
DialogOptions.yes,
126-
DialogOptions.no,
127-
);
128-
if (action !== DialogOptions.yes) {
129-
return;
130-
}
124+
// const action: vscode.MessageItem | undefined = await vscode.window.showWarningMessage(
125+
// `This operation cannot be reverted. Are you sure to delete the session: ${selectedSession.name}?`,
126+
// DialogOptions.yes,
127+
// DialogOptions.no,
128+
// );
129+
// if (action !== DialogOptions.yes) {
130+
// return;
131+
// }
131132

132-
const confirm: string | undefined = await vscode.window.showInputBox({
133-
prompt: "Enter 'yes' to confirm deleting the session",
134-
validateInput: (value: string): string => {
135-
if (value === "yes") {
136-
return "";
137-
} else {
138-
return "Enter 'yes' to confirm";
139-
}
140-
},
141-
});
133+
// const confirm: string | undefined = await vscode.window.showInputBox({
134+
// prompt: "Enter 'yes' to confirm deleting the session",
135+
// validateInput: (value: string): string => {
136+
// if (value === "yes") {
137+
// return "";
138+
// } else {
139+
// return "Enter 'yes' to confirm";
140+
// }
141+
// },
142+
// });
142143

143-
if (confirm === "yes") {
144-
await leetCodeExecutor.deleteSession(selectedSession.id);
145-
vscode.window.showInformationMessage("The session has been successfully deleted.");
146-
}
147-
}
144+
// if (confirm === "yes") {
145+
// await leetCodeExecutor.deleteSession(selectedSession.id);
146+
// vscode.window.showInformationMessage("The session has been successfully deleted.");
147+
// }
148+
// }
148149

149150
export interface ISession {
150151
active: boolean;

0 commit comments

Comments
 (0)