Skip to content

Support showing description from text document #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
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
Next Next commit
Add problem pool to tree provider
  • Loading branch information
Vigilans committed Apr 26, 2019
commit 27c9da47d49c5a40c945b82883a614e120f0f292
9 changes: 9 additions & 0 deletions src/explorer/LeetCodeTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { LeetCodeNode } from "./LeetCodeNode";

export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCodeNode> {

private problemPool: Map<string, IProblem>; // maintains the ownership of all problems.

private treeData: {
Difficulty: Map<string, IProblem[]>,
Tag: Map<string, IProblem[]>,
Expand All @@ -32,6 +34,10 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
this.onDidChangeTreeDataEvent.fire();
}

public getProblem(id: string): IProblem | undefined {
return this.problemPool.get(id);
}

public getTreeItem(element: LeetCodeNode): vscode.TreeItem | Thenable<vscode.TreeItem> {
if (element.id === "notSignIn") {
return {
Expand Down Expand Up @@ -102,13 +108,16 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod

private async getProblemData(): Promise<void> {
// clear cache
this.problemPool = new Map<string, IProblem>();
this.treeData = {
Difficulty: new Map<string, IProblem[]>(),
Tag: new Map<string, IProblem[]>(),
Company: new Map<string, IProblem[]>(),
Favorite: [],
};
for (const problem of await list.listProblems()) {
// Add every problem to problem pool
this.problemPool.set(problem.id, problem);
// Add favorite problem, no matter whether it is solved.
if (problem.isFavorite) {
this.treeData[Category.Favorite].push(problem);
Expand Down