@@ -3,7 +3,17 @@ import { Notification } from '@jupyterlab/apputils';
33import { listQuestions } from '../services/leetcode' ;
44import { LeetCodeQuestion , LeetCodeQuestionQuery } from '../types/leetcode' ;
55import QuestionItem from './QuestionItem' ;
6- import { Table , Text , Stack , ScrollArea , Skeleton , Group } from '@mantine/core' ;
6+ import {
7+ Table ,
8+ Text ,
9+ Stack ,
10+ ScrollArea ,
11+ Skeleton ,
12+ Group ,
13+ Transition ,
14+ Center ,
15+ Loader
16+ } from '@mantine/core' ;
717import QuestionQueryKeyword from './QuestionQueryKeyword' ;
818import QuestionDifficultyFilter from './QuestionDifficultyFilter' ;
919import QuestionStatusFilter from './QuestionStatusFilter' ;
@@ -20,6 +30,7 @@ const QuestionTable: React.FC<{
2030 const [ skip , setSkip ] = useState ( 0 ) ;
2131 const [ questions , setQuestions ] = useState < LeetCodeQuestion [ ] > ( [ ] ) ;
2232 const [ hasMore , setHasMore ] = useState ( true ) ;
33+ const [ fetchingMore , setFetchingMore ] = useState ( false ) ;
2334
2435 const [ query , setQuery ] = useState < LeetCodeQuestionQuery > ( {
2536 keyword : '' ,
@@ -41,6 +52,7 @@ const QuestionTable: React.FC<{
4152 . then ( ( { problemsetQuestionListV2 } ) => {
4253 const qs = fetching ? [ ] : questions ; // fix datarace to ensure distinct key
4354 setFetching ( false ) ;
55+ setFetchingMore ( false ) ;
4456 const { questions : fetchedQuestions , hasMore : fetchedHasMore } =
4557 problemsetQuestionListV2 ;
4658 setQuestions ( qs . concat ( fetchedQuestions ) ) ;
@@ -103,10 +115,14 @@ const QuestionTable: React.FC<{
103115 updateCompanies = { cs => updateQuery ( { ...query , companies : cs } ) }
104116 />
105117 </ Group >
106- { /* TODO: show fetching more loading icon */ }
107118 < ScrollArea
108119 type = "scroll"
109- onBottomReached = { ( ) => ( hasMore ? setSkip ( s => s + limit ) : null ) }
120+ onBottomReached = { ( ) => {
121+ if ( ! fetchingMore && hasMore ) {
122+ setFetchingMore ( true ) ;
123+ setSkip ( s => s + limit ) ;
124+ }
125+ } }
110126 >
111127 < Table
112128 striped
@@ -116,6 +132,18 @@ const QuestionTable: React.FC<{
116132 >
117133 < Table . Tbody > { getTableRows ( ) } </ Table . Tbody >
118134 </ Table >
135+ < Transition
136+ mounted = { fetchingMore }
137+ transition = "fade"
138+ duration = { 400 }
139+ timingFunction = "ease"
140+ >
141+ { styles => (
142+ < Center style = { styles } >
143+ < Loader size = "xs" />
144+ </ Center >
145+ ) }
146+ </ Transition >
119147 </ ScrollArea >
120148 </ Stack >
121149 ) ;
0 commit comments