@@ -4,6 +4,7 @@ import * as path from "path";
4
4
import * as vscode from "vscode" ;
5
5
import * as list from "./commands/list" ;
6
6
import { leetCodeManager } from "./leetCodeManager" ;
7
+ import { ProblemState } from "./shared" ;
7
8
8
9
// tslint:disable:max-classes-per-file
9
10
export class LeetCodeNode {
@@ -13,8 +14,8 @@ export class LeetCodeNode {
13
14
return this . data . name ;
14
15
}
15
16
16
- public get solved ( ) : boolean {
17
- return this . data . solved ;
17
+ public get state ( ) : ProblemState {
18
+ return this . data . state ;
18
19
}
19
20
20
21
public get id ( ) : string {
@@ -64,11 +65,7 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
64
65
id : `${ idPrefix } .${ element . id } ` ,
65
66
collapsibleState : element . isProblem ? vscode . TreeItemCollapsibleState . None : vscode . TreeItemCollapsibleState . Collapsed ,
66
67
contextValue : element . isProblem ? "problem" : "difficulty" ,
67
- iconPath : element . isProblem ?
68
- ( element . solved ?
69
- this . context . asAbsolutePath ( path . join ( "resources" , "check.png" ) )
70
- : this . context . asAbsolutePath ( path . join ( "resources" , "blank.png" ) ) )
71
- : "" ,
68
+ iconPath : this . parseIconPathFromProblemState ( element ) ,
72
69
} ;
73
70
}
74
71
@@ -77,7 +74,7 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
77
74
return [
78
75
new LeetCodeNode (
79
76
{
80
- solved : false ,
77
+ state : ProblemState . Unknown ,
81
78
id : "notSignIn" ,
82
79
name : "Sign in to LeetCode" ,
83
80
difficulty : "" ,
@@ -128,7 +125,7 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
128
125
difficultynodes . push (
129
126
new LeetCodeNode (
130
127
{
131
- solved : false ,
128
+ state : ProblemState . Unknown ,
132
129
id : difficulty ,
133
130
name : difficulty ,
134
131
difficulty : "" ,
@@ -155,4 +152,20 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
155
152
} ) ;
156
153
return difficultynodes ;
157
154
}
155
+
156
+ private parseIconPathFromProblemState ( element : LeetCodeNode ) : string {
157
+ if ( ! element . isProblem ) {
158
+ return "" ;
159
+ }
160
+ switch ( element . state ) {
161
+ case ProblemState . AC :
162
+ return this . context . asAbsolutePath ( path . join ( "resources" , "check.png" ) ) ;
163
+ case ProblemState . NotAC :
164
+ return this . context . asAbsolutePath ( path . join ( "resources" , "x.png" ) ) ;
165
+ case ProblemState . Unknown :
166
+ return this . context . asAbsolutePath ( path . join ( "resources" , "blank.png" ) ) ;
167
+ default :
168
+ return "" ;
169
+ }
170
+ }
158
171
}
0 commit comments