mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20:24 +03:00
Make sure the request to get the latest fallback visit respects bots config
This commit is contained in:
parent
d18219dc14
commit
8acf6dda6e
2 changed files with 8 additions and 10 deletions
|
@ -20,7 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
* *Nothing*
|
* *Nothing*
|
||||||
|
|
||||||
### Fixed
|
### 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
|
## [3.9.1] - 2022-12-31
|
||||||
|
|
|
@ -18,7 +18,7 @@ const isLastPage = ({ currentPage, pagesCount }: ShlinkPaginator): boolean => cu
|
||||||
const calcProgress = (total: number, current: number): number => (current * 100) / total;
|
const calcProgress = (total: number, current: number): number => (current * 100) / total;
|
||||||
|
|
||||||
type VisitsLoader = (page: number, itemsPerPage: number) => Promise<ShlinkVisits>;
|
type VisitsLoader = (page: number, itemsPerPage: number) => Promise<ShlinkVisits>;
|
||||||
type LastVisitLoader = () => Promise<Visit | undefined>;
|
type LastVisitLoader = (excludeBots?: boolean) => Promise<Visit | undefined>;
|
||||||
|
|
||||||
interface VisitsAsyncThunkOptions<T extends LoadVisits = LoadVisits, R extends VisitsLoaded = VisitsLoaded> {
|
interface VisitsAsyncThunkOptions<T extends LoadVisits = LoadVisits, R extends VisitsLoaded = VisitsLoaded> {
|
||||||
typePrefix: string;
|
typePrefix: string;
|
||||||
|
@ -75,7 +75,7 @@ export const createVisitsAsyncThunk = <T extends LoadVisits = LoadVisits, R exte
|
||||||
return data.concat(await loadPagesBlocks(pagesBlocks));
|
return data.concat(await loadPagesBlocks(pagesBlocks));
|
||||||
};
|
};
|
||||||
|
|
||||||
const [visits, lastVisit] = await Promise.all([loadVisits(), lastVisitLoader()]);
|
const [visits, lastVisit] = await Promise.all([loadVisits(), lastVisitLoader(params.query?.excludeBots)]);
|
||||||
|
|
||||||
if (!visits.length && lastVisit) {
|
if (!visits.length && lastVisit) {
|
||||||
dispatch(fallbackToInterval(dateToMatchingInterval(lastVisit.date)));
|
dispatch(fallbackToInterval(dateToMatchingInterval(lastVisit.date)));
|
||||||
|
@ -91,13 +91,11 @@ export const createVisitsAsyncThunk = <T extends LoadVisits = LoadVisits, R exte
|
||||||
export const lastVisitLoaderForLoader = (
|
export const lastVisitLoaderForLoader = (
|
||||||
doIntervalFallback: boolean,
|
doIntervalFallback: boolean,
|
||||||
loader: (params: ShlinkVisitsParams) => Promise<ShlinkVisits>,
|
loader: (params: ShlinkVisitsParams) => Promise<ShlinkVisits>,
|
||||||
): LastVisitLoader => {
|
): LastVisitLoader => async (excludeBots?: boolean) => (
|
||||||
if (!doIntervalFallback) {
|
!doIntervalFallback
|
||||||
return async () => Promise.resolve(undefined);
|
? Promise.resolve(undefined)
|
||||||
}
|
: loader({ page: 1, itemsPerPage: 1, excludeBots }).then(({ data }) => data[0])
|
||||||
|
);
|
||||||
return async () => loader({ page: 1, itemsPerPage: 1 }).then(({ data }) => data[0]);
|
|
||||||
};
|
|
||||||
|
|
||||||
interface VisitsReducerOptions<State extends VisitsInfo, AT extends ReturnType<typeof createVisitsAsyncThunk>> {
|
interface VisitsReducerOptions<State extends VisitsInfo, AT extends ReturnType<typeof createVisitsAsyncThunk>> {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
Loading…
Reference in a new issue