From 8acf6dda6eb6965ddfb95cba653a1fed19106334 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 10 Mar 2023 08:53:05 +0100 Subject: [PATCH] Make sure the request to get the latest fallback visit respects bots config --- CHANGELOG.md | 2 +- src/visits/reducers/common.ts | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6bd9990..211c2589 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), * *Nothing* ### Fixed -* *Nothing* +* [#799](https://github.com/shlinkio/shlink-web-client/issues/799) Fix fallback visits not taking into account configuration regarding excluding bots. ## [3.9.1] - 2022-12-31 diff --git a/src/visits/reducers/common.ts b/src/visits/reducers/common.ts index fe7183ac..de5f33dc 100644 --- a/src/visits/reducers/common.ts +++ b/src/visits/reducers/common.ts @@ -18,7 +18,7 @@ const isLastPage = ({ currentPage, pagesCount }: ShlinkPaginator): boolean => cu const calcProgress = (total: number, current: number): number => (current * 100) / total; type VisitsLoader = (page: number, itemsPerPage: number) => Promise; -type LastVisitLoader = () => Promise; +type LastVisitLoader = (excludeBots?: boolean) => Promise; interface VisitsAsyncThunkOptions { typePrefix: string; @@ -75,7 +75,7 @@ export const createVisitsAsyncThunk = Promise, -): LastVisitLoader => { - if (!doIntervalFallback) { - return async () => Promise.resolve(undefined); - } - - return async () => loader({ page: 1, itemsPerPage: 1 }).then(({ data }) => data[0]); -}; +): LastVisitLoader => async (excludeBots?: boolean) => ( + !doIntervalFallback + ? Promise.resolve(undefined) + : loader({ page: 1, itemsPerPage: 1, excludeBots }).then(({ data }) => data[0]) +); interface VisitsReducerOptions> { name: string;