-
Notifications
You must be signed in to change notification settings - Fork 679
Enhanced Tree view #94
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
Changes from 1 commit
e90b44e
c1a58b2
ce204b9
236a020
64badc5
d648f8a
21723fe
39071bf
3cb8743
86f17ac
7e00062
0153d84
d9abd5f
7bffd54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,8 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod | |
Favorite: list.IProblem[], | ||
}; | ||
|
||
private leetCodeConfig: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("leetcode"); | ||
|
||
private onDidChangeTreeDataEvent: vscode.EventEmitter<any> = new vscode.EventEmitter<any>(); | ||
// tslint:disable-next-line:member-ordering | ||
public readonly onDidChangeTreeData: vscode.Event<any> = this.onDidChangeTreeDataEvent.event; | ||
|
@@ -133,6 +135,14 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod | |
Favorite: [], | ||
}; | ||
for (const problem of await list.listProblems()) { | ||
// Add favorite problem, no matter whether it is solved. | ||
if (problem.favorite) { | ||
this.treeData.Favorite.push(problem); | ||
} | ||
// Hide solved problem in category view is specified in option. | ||
if (problem.state === ProblemState.AC && this.leetCodeConfig.get<boolean>("hideSolved")) { | ||
continue; | ||
} | ||
// Add problems according to category | ||
const categories: Array<[Category, string[]]> = [ | ||
|
||
["Difficulty", [problem.difficulty]], | ||
|
@@ -151,10 +161,6 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod | |
} | ||
} | ||
} | ||
// Add favorite problems | ||
if (problem.favorite) { | ||
this.treeData.Favorite.push(problem); | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking that we can filter the accepted problems in the method
list.listProblems()
. IfhideSolved === true
then only return unaccepted problems.By doing this, we decouple the
this.leetCodeConfig
with the explorerUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion,
Favorite
group should show all starred problems no matter whether it's accepted or not.Maybe it could be checked this way in
list.listProblems()
:!problem.favorite && problem.state === ProblemState.AC && hideSolved
->continue
The flaw is that the favorite checking logic is duplicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, ok, just keep it there first.