fix: PaginatedList loading loop
This commit is contained in:
@@ -6,6 +6,7 @@ import * as React from "react";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
import { useHistory, useLocation } from "react-router-dom";
|
||||
import scrollIntoView from "smooth-scroll-into-view-if-needed";
|
||||
import { PAGINATION_SYMBOL } from "stores/BaseStore";
|
||||
import Invite from "scenes/Invite";
|
||||
import { Action } from "components/Actions";
|
||||
import Button from "components/Button";
|
||||
@@ -56,8 +57,8 @@ function People(props) {
|
||||
filter,
|
||||
});
|
||||
|
||||
setTotalPages(Math.ceil(response.pagination.total / limit));
|
||||
setUserIds(response.data.map((u) => u.id));
|
||||
setTotalPages(Math.ceil(response[PAGINATION_SYMBOL].total / limit));
|
||||
setUserIds(response.map((u) => u.id));
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ function modelNameFromClassName(string) {
|
||||
|
||||
export const DEFAULT_PAGINATION_LIMIT = 25;
|
||||
|
||||
export const PAGINATION_SYMBOL = Symbol.for("pagination");
|
||||
|
||||
export default class BaseStore<T: BaseModel> {
|
||||
@observable data: Map<string, T> = new Map();
|
||||
@observable isFetching: boolean = false;
|
||||
@@ -175,7 +177,10 @@ export default class BaseStore<T: BaseModel> {
|
||||
res.data.forEach(this.add);
|
||||
this.isLoaded = true;
|
||||
});
|
||||
return res;
|
||||
|
||||
let response = res.data;
|
||||
response[PAGINATION_SYMBOL] = res.pagination;
|
||||
return response;
|
||||
} finally {
|
||||
this.isFetching = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user