forked from LeetCode-OpenSource/vscode-leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstar.ts
26 lines (22 loc) · 1.06 KB
/
star.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright (c) jdneo. All rights reserved.
// Licensed under the MIT license.
import { LeetCodeNode } from "../explorer/LeetCodeNode";
import { leetCodeTreeDataProvider } from "../explorer/LeetCodeTreeDataProvider";
import { leetCodeExecutor } from "../leetCodeExecutor";
import { DialogType, promptForOpenOutputChannel } from "../utils/uiUtils";
export async function addFavorite(node: LeetCodeNode): Promise<void> {
try {
await leetCodeExecutor.toggleFavorite(node, true);
leetCodeTreeDataProvider.refresh();
} catch (error) {
await promptForOpenOutputChannel("Failed to add the problem to favorite. Please open the output channel for details.", DialogType.error);
}
}
export async function removeFavorite(node: LeetCodeNode): Promise<void> {
try {
await leetCodeExecutor.toggleFavorite(node, false);
leetCodeTreeDataProvider.refresh();
} catch (error) {
await promptForOpenOutputChannel("Failed to remove the problem from favorite. Please open the output channel for details.", DialogType.error);
}
}