Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add daily challenge category and implement related node retrieval
  • Loading branch information
XzZZzX02 committed Nov 17, 2024
commit 0696a48d554584fe73870eb3b6108755bb0d4d41
2 changes: 2 additions & 0 deletions src/explorer/LeetCodeTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
return explorerNodeManager.getAllTagNodes();
case Category.Company:
return explorerNodeManager.getAllCompanyNodes();
case Category.Daily:
return explorerNodeManager.getDailyChallengeNode();
default:
if (element.isProblem) {
return [];
Expand Down
10 changes: 10 additions & 0 deletions src/explorer/explorerNodeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getSortingStrategy } from "../commands/plugin";
import { Category, defaultProblem, ProblemState, SortingStrategy } from "../shared";
import { shouldHideSolvedProblem } from "../utils/settingUtils";
import { LeetCodeNode } from "./LeetCodeNode";
import { queryDailyChallenge } from "../request/query-daily-challange";

class ExplorerNodeManager implements Disposable {
private explorerNodeMap: Map<string, LeetCodeNode> = new Map<string, LeetCodeNode>();
Expand Down Expand Up @@ -53,6 +54,10 @@ class ExplorerNodeManager implements Disposable {
id: Category.Favorite,
name: Category.Favorite,
}), false),
new LeetCodeNode(Object.assign({}, defaultProblem, {
id: Category.Daily,
name: Category.Daily,
}), false)
];
}

Expand Down Expand Up @@ -148,6 +153,11 @@ class ExplorerNodeManager implements Disposable {
return this.applySortingStrategy(res);
}

public async getDailyChallengeNode(): Promise<LeetCodeNode[]> {
const dailyChallengeID: string = await queryDailyChallenge();
return this.getNodeById(dailyChallengeID) ? [this.getNodeById(dailyChallengeID)!] : [];
}

public dispose(): void {
this.explorerNodeMap.clear();
this.companySet.clear();
Expand Down
1 change: 1 addition & 0 deletions src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export enum Category {
Tag = "Tag",
Company = "Company",
Favorite = "Favorite",
Daily = "Daily Challenge"
}

export const supportedPlugins: string[] = ["company", "solution.discuss", "leetcode.cn"];
Expand Down