Skip to content

Commit 8c7e9d3

Browse files
programatically paginate to fetch all work items
1 parent e19cec9 commit 8c7e9d3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src-ts/lib/work-provider/work.provider.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ export const WorkProvider: FC<{ children: ReactNode }> = ({ children }: { childr
3232
fieldName: 'created',
3333
},
3434
}
35-
const work: Array<Work> = await workGetAsync((profile as UserProfile).handle, page)
35+
let work: Array<Work> = [];
36+
let nextSet: Array<Work> = await workGetAsync((profile as UserProfile).handle, page)
37+
38+
while (nextSet.length > 0) {
39+
work = work.concat(nextSet);
40+
page.number += 1;
41+
nextSet = await workGetAsync((profile as UserProfile).handle, page)
42+
}
3643

3744
const contextData: WorkContextData = {
3845
deleteWorkAsync,

0 commit comments

Comments
 (0)