items are fetched by batch of 100
This commit is contained in:
parent
01497dbe8f
commit
8bb8d59770
@ -14,12 +14,7 @@ const WebhookWrapper = styled.div`
|
||||
`;
|
||||
|
||||
const WebhookHistory = (props) => {
|
||||
const {
|
||||
historyItems,
|
||||
fetchHistoryItems,
|
||||
emptyCheckedIds,
|
||||
clearHistoryFilters,
|
||||
} = props;
|
||||
const { historyItems, fetchHistoryItems, emptyCheckedIds, clearHistoryFilters } = props;
|
||||
|
||||
const [isFetchFinished, setIsFetchFinished] = useState(false);
|
||||
const [isPending, startTransition] = useTransition();
|
||||
@ -29,7 +24,6 @@ const WebhookHistory = (props) => {
|
||||
const fetchItems = async () => {
|
||||
await fetchHistoryItems({
|
||||
configId: id,
|
||||
count: 30,
|
||||
});
|
||||
setIsFetchFinished(true);
|
||||
};
|
||||
@ -42,7 +36,7 @@ const WebhookHistory = (props) => {
|
||||
|
||||
const applyFilters = async ({ deliveryFrom, deliveryTo, groupStatus }) => {
|
||||
emptyCheckedIds();
|
||||
const params = { configId: id, deliveryFrom, deliveryTo, groupStatus, count: 30 };
|
||||
const params = { configId: id, deliveryFrom, deliveryTo, groupStatus };
|
||||
|
||||
await fetchHistoryItems(params);
|
||||
};
|
||||
@ -64,12 +58,7 @@ const WebhookHistory = (props) => {
|
||||
};
|
||||
|
||||
export default inject(({ webhooksStore }) => {
|
||||
const {
|
||||
historyItems,
|
||||
fetchHistoryItems,
|
||||
emptyCheckedIds,
|
||||
clearHistoryFilters,
|
||||
} = webhooksStore;
|
||||
const { historyItems, fetchHistoryItems, emptyCheckedIds, clearHistoryFilters } = webhooksStore;
|
||||
|
||||
return {
|
||||
historyItems,
|
||||
|
@ -124,7 +124,6 @@ const HistoryHeader = (props) => {
|
||||
await retryWebhookEvents(checkedEventIds);
|
||||
fetchHistoryItems({
|
||||
configId: id,
|
||||
count: 30,
|
||||
});
|
||||
toastr.success(
|
||||
`${t("WebhookRedilivered")}: ${checkedEventIds.length}`,
|
||||
|
@ -54,7 +54,7 @@ const HistoryRowView = (props) => {
|
||||
|
||||
const fetchMoreFiles = () => {
|
||||
const params = historyFilters === null ? {} : formatFilters(historyFilters);
|
||||
fetchMoreItems({ ...params, configId: id, count: 10 });
|
||||
fetchMoreItems({ ...params, configId: id });
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -78,7 +78,7 @@ const HistoryTableView = (props) => {
|
||||
|
||||
const fetchMoreFiles = () => {
|
||||
const params = historyFilters === null ? {} : formatFilters(historyFilters);
|
||||
fetchMoreItems({ ...params, configId: id, count: 10 });
|
||||
fetchMoreItems({ ...params, configId: id });
|
||||
};
|
||||
|
||||
const columnStorageName = `${COLUMNS_SIZE}=${userId}`;
|
||||
|
@ -20,6 +20,7 @@ class WebhooksStore {
|
||||
developerToolsTab = 0;
|
||||
currentWebhook = {};
|
||||
eventDetails = {};
|
||||
FETCH_COUNT = 100;
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
@ -110,18 +111,29 @@ class WebhooksStore {
|
||||
};
|
||||
|
||||
fetchHistoryItems = async (params) => {
|
||||
this.totalItems = 0;
|
||||
this.startIndex = 0;
|
||||
const historyData = await getWebhooksJournal({ ...params, startIndex: this.startIndex });
|
||||
const count = params.count ? params.count : this.FETCH_COUNT;
|
||||
const historyData = await getWebhooksJournal({
|
||||
...params,
|
||||
startIndex: this.startIndex,
|
||||
count: count,
|
||||
});
|
||||
runInAction(() => {
|
||||
this.startIndex = params.count;
|
||||
this.startIndex = count;
|
||||
this.historyItems = historyData.items;
|
||||
this.totalItems = historyData.total;
|
||||
});
|
||||
};
|
||||
fetchMoreItems = async (params) => {
|
||||
const historyData = await getWebhooksJournal({ ...params, startIndex: this.startIndex });
|
||||
const count = params.count ? params.count : this.FETCH_COUNT;
|
||||
const historyData = await getWebhooksJournal({
|
||||
...params,
|
||||
startIndex: this.startIndex,
|
||||
count: count,
|
||||
});
|
||||
runInAction(() => {
|
||||
this.startIndex = this.startIndex + params.count;
|
||||
this.startIndex = this.startIndex + count;
|
||||
this.historyItems = [...this.historyItems, ...historyData.items];
|
||||
});
|
||||
};
|
||||
@ -130,7 +142,7 @@ class WebhooksStore {
|
||||
this.eventDetails = data.items[0];
|
||||
};
|
||||
get hasMoreItems() {
|
||||
return this.totalItems > this.historyItems.length;
|
||||
return this.totalItems > this.startIndex;
|
||||
}
|
||||
|
||||
get isWebhooksEmpty() {
|
||||
|
Loading…
Reference in New Issue
Block a user