File tree 1 file changed +15
-15
lines changed
1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change 1
- import { ContestInfo , ContestRanking , LeetCode , UserContestInfo } from "leetcode-query" ;
1
+ import { ContestInfo , ContestRanking , LeetCode } from "leetcode-query" ;
2
2
import { Generator } from "../card" ;
3
3
import { Item } from "../item" ;
4
4
import { Extension } from "../types" ;
@@ -7,23 +7,23 @@ export async function ContestExtension(generator: Generator): Promise<Extension>
7
7
const pre_result = new Promise < null | { ranking : ContestRanking ; history : ContestInfo [ ] } > (
8
8
( resolve ) => {
9
9
const lc = new LeetCode ( ) ;
10
- lc . once ( "receive-graphql" , async ( res ) => {
11
- try {
12
- const { data } = ( await res . json ( ) ) as { data : UserContestInfo } ;
13
- const history = data . userContestRankingHistory . filter ( ( x ) => x . attended ) ;
10
+ lc . user_contest_info ( generator . config . username )
11
+ . then ( ( data ) => {
12
+ try {
13
+ const history = data . userContestRankingHistory . filter ( ( x ) => x . attended ) ;
14
14
15
- if ( history . length === 0 ) {
15
+ if ( history . length === 0 ) {
16
+ resolve ( null ) ;
17
+ return ;
18
+ }
19
+
20
+ resolve ( { ranking : data . userContestRanking , history } ) ;
21
+ } catch ( e ) {
22
+ console . error ( e ) ;
16
23
resolve ( null ) ;
17
- return ;
18
24
}
19
-
20
- resolve ( { ranking : data . userContestRanking , history } ) ;
21
- } catch ( e ) {
22
- console . error ( e ) ;
23
- resolve ( null ) ;
24
- }
25
- } ) ;
26
- lc . user_contest_info ( generator . config . username ) . catch ( ( ) => resolve ( null ) ) ;
25
+ } )
26
+ . catch ( ( ) => resolve ( null ) ) ;
27
27
} ,
28
28
) ;
29
29
You can’t perform that action at this time.
0 commit comments