MCPcopy Create free account
hub / github.com/LeetCode-OpenSource/vscode-leetcode / deleteSession

Function deleteSession

src/commands/session.ts:108–147  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106}
107
108async 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 }
116
117 const selectedSession: ISession = choice.value as ISession;
118 if (selectedSession.active) {
119 vscode.window.showInformationMessage("Cannot delete an active session.");
120 return;
121 }
122
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 }
131
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 });
142
143 if (confirm === "yes") {
144 await leetCodeExecutor.deleteSession(selectedSession.id);
145 vscode.window.showInformationMessage("The session has been successfully deleted.");
146 }
147}
148
149export interface ISession {
150 active: boolean;

Callers 1

manageSessionsFunction · 0.85

Calls 2

parseSessionsToPicksFunction · 0.85
deleteSessionMethod · 0.80

Tested by

no test coverage detected