From 8bb8d5977035466ad195fdc3d589684522c6e58d Mon Sep 17 00:00:00 2001 From: Vladimir Khvan Date: Wed, 7 Jun 2023 21:22:24 +0500 Subject: [PATCH] items are fetched by batch of 100 --- .../Webhooks/WebhookHistory/index.js | 17 +++----------- .../sub-components/HistoryHeader.js | 1 - .../HistoryRowView/index.js | 2 +- .../HistoryTableView/index.js | 2 +- packages/client/src/store/WebhooksStore.js | 22 ++++++++++++++----- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/index.js b/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/index.js index 3740a401c4..f984072ae9 100644 --- a/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/index.js +++ b/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/index.js @@ -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, diff --git a/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/sub-components/HistoryHeader.js b/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/sub-components/HistoryHeader.js index 5bbb414239..3f64916822 100644 --- a/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/sub-components/HistoryHeader.js +++ b/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/sub-components/HistoryHeader.js @@ -124,7 +124,6 @@ const HistoryHeader = (props) => { await retryWebhookEvents(checkedEventIds); fetchHistoryItems({ configId: id, - count: 30, }); toastr.success( `${t("WebhookRedilivered")}: ${checkedEventIds.length}`, diff --git a/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/sub-components/WebhookHistoryTable/HistoryRowView/index.js b/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/sub-components/WebhookHistoryTable/HistoryRowView/index.js index 94e3581f98..746d2f0316 100644 --- a/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/sub-components/WebhookHistoryTable/HistoryRowView/index.js +++ b/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/sub-components/WebhookHistoryTable/HistoryRowView/index.js @@ -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 ( diff --git a/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/sub-components/WebhookHistoryTable/HistoryTableView/index.js b/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/sub-components/WebhookHistoryTable/HistoryTableView/index.js index 06d092fb3c..388d79ecc8 100644 --- a/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/sub-components/WebhookHistoryTable/HistoryTableView/index.js +++ b/packages/client/src/pages/PortalSettings/categories/developer-tools/Webhooks/WebhookHistory/sub-components/WebhookHistoryTable/HistoryTableView/index.js @@ -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}`; diff --git a/packages/client/src/store/WebhooksStore.js b/packages/client/src/store/WebhooksStore.js index e3563d3ea2..76e46c8072 100644 --- a/packages/client/src/store/WebhooksStore.js +++ b/packages/client/src/store/WebhooksStore.js @@ -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() {