File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Expand file tree Collapse file tree 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" ;
22import { Generator } from "../card" ;
33import { Item } from "../item" ;
44import { Extension } from "../types" ;
@@ -7,23 +7,23 @@ export async function ContestExtension(generator: Generator): Promise<Extension>
77 const pre_result = new Promise < null | { ranking : ContestRanking ; history : ContestInfo [ ] } > (
88 ( resolve ) => {
99 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 ) ;
1414
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 ) ;
1623 resolve ( null ) ;
17- return ;
1824 }
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 ) ) ;
2727 } ,
2828 ) ;
2929
You can’t perform that action at this time.
0 commit comments