Просмотр исходного кода

feat(feedback): Fetch larger pages than the default, if the virtualized-list asks for it (#57688)

Ryan Albrecht 1 год назад
Родитель
Сommit
b29efaef31

+ 6 - 6
static/app/components/feedback/useFetchFeedbackInfiniteListData.tsx

@@ -172,7 +172,7 @@ class InfiniteListLoader {
     };
   }
 
-  public async fetchNext() {
+  public async fetchNext(perPage: number = PER_PAGE) {
     if (this.hasMore !== true) {
       // Skip the request if we either:
       // - Have not yet got the first results back
@@ -182,14 +182,14 @@ class InfiniteListLoader {
 
     const result = await this.fetch({
       end: this.minDatetime,
-      perPage: PER_PAGE,
+      perPage,
       sort: '-timestamp',
       start: startDateFromQueryView(this.queryView),
     });
     this.didFetchNext(result);
   }
 
-  public async fetchPrev() {
+  public async fetchPrev(perPage: number = PER_PAGE) {
     if (this.hasPrev !== false) {
       // Skip the request if:
       // - We know there are no more results to fetch
@@ -198,7 +198,7 @@ class InfiniteListLoader {
 
     const result = await this.fetch({
       end: endDateFromQueryView(this.queryView),
-      perPage: PER_PAGE,
+      perPage,
       sort: 'timestamp',
       start: this.maxDatetime,
     });
@@ -279,8 +279,8 @@ export default function useFetchFeedbackInfiniteListData({
     [state.items]
   );
 
-  const loadMoreRows = useCallback(({startIndex: _1, stopIndex: _2}: IndexRange) => {
-    return loaderRef.current?.fetchNext() ?? Promise.resolve();
+  const loadMoreRows = useCallback(({startIndex, stopIndex}: IndexRange) => {
+    return loaderRef.current?.fetchNext(stopIndex - startIndex) ?? Promise.resolve();
   }, []);
 
   const updateFeedback = useCallback(({feedbackId: _}: {feedbackId: string}) => {