mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Ensured bots exclusion is selected by default in visits filter dropdown, if it was selected in settings
This commit is contained in:
parent
5942cd6fcf
commit
80cea91339
2 changed files with 12 additions and 6 deletions
|
@ -93,6 +93,12 @@ export const VisitsStats: FC<VisitsStatsProps> = ({
|
||||||
[normalizedVisits],
|
[normalizedVisits],
|
||||||
);
|
);
|
||||||
const mapLocations = values(citiesForMap);
|
const mapLocations = values(citiesForMap);
|
||||||
|
const resolvedFilter = useMemo(() => (
|
||||||
|
!isFirstLoad.current ? visitsFilter : {
|
||||||
|
...visitsFilter,
|
||||||
|
excludeBots: visitsFilter.excludeBots ?? settings.visits?.excludeBots,
|
||||||
|
}
|
||||||
|
), [visitsFilter]);
|
||||||
|
|
||||||
const setSelectedVisits = (selectedVisits: NormalizedVisit[]) => {
|
const setSelectedVisits = (selectedVisits: NormalizedVisit[]) => {
|
||||||
selectedBar = undefined;
|
selectedBar = undefined;
|
||||||
|
@ -115,7 +121,7 @@ export const VisitsStats: FC<VisitsStatsProps> = ({
|
||||||
useEffect(() => cancelGetVisits, []);
|
useEffect(() => cancelGetVisits, []);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const resolvedDateRange = !isFirstLoad.current ? dateRange : (dateRange ?? toDateRange(initialInterval.current));
|
const resolvedDateRange = !isFirstLoad.current ? dateRange : (dateRange ?? toDateRange(initialInterval.current));
|
||||||
getVisits({ dateRange: resolvedDateRange, filter: visitsFilter }, isFirstLoad.current);
|
getVisits({ dateRange: resolvedDateRange, filter: resolvedFilter }, isFirstLoad.current);
|
||||||
isFirstLoad.current = false;
|
isFirstLoad.current = false;
|
||||||
}, [dateRange, visitsFilter]);
|
}, [dateRange, visitsFilter]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -301,7 +307,7 @@ export const VisitsStats: FC<VisitsStatsProps> = ({
|
||||||
className="ms-0 ms-md-2 mt-3 mt-md-0"
|
className="ms-0 ms-md-2 mt-3 mt-md-0"
|
||||||
isOrphanVisits={isOrphanVisits}
|
isOrphanVisits={isOrphanVisits}
|
||||||
botsSupported={botsSupported}
|
botsSupported={botsSupported}
|
||||||
selected={visitsFilter}
|
selected={resolvedFilter}
|
||||||
onChange={(newVisitsFilter) => updateFiltering({ visitsFilter: newVisitsFilter })}
|
onChange={(newVisitsFilter) => updateFiltering({ visitsFilter: newVisitsFilter })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { DeepPartial } from '@reduxjs/toolkit';
|
import { DeepPartial } from '@reduxjs/toolkit';
|
||||||
import { useLocation, useNavigate } from 'react-router-dom';
|
import { useLocation, useNavigate } from 'react-router-dom';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { isEmpty, mergeDeepRight, pipe } from 'ramda';
|
import { isEmpty, isNil, mergeDeepRight, pipe } from 'ramda';
|
||||||
import { DateRange, datesToDateRange } from '../../utils/helpers/dateIntervals';
|
import { DateRange, datesToDateRange } from '../../utils/helpers/dateIntervals';
|
||||||
import { OrphanVisitType, VisitsFilter } from '../types';
|
import { OrphanVisitType, VisitsFilter } from '../types';
|
||||||
import { parseQuery, stringifyQuery } from '../../utils/helpers/query';
|
import { parseQuery, stringifyQuery } from '../../utils/helpers/query';
|
||||||
|
@ -11,7 +11,7 @@ interface VisitsQuery {
|
||||||
startDate?: string;
|
startDate?: string;
|
||||||
endDate?: string;
|
endDate?: string;
|
||||||
orphanVisitsType?: OrphanVisitType;
|
orphanVisitsType?: OrphanVisitType;
|
||||||
excludeBots?: 'true';
|
excludeBots?: 'true' | 'false';
|
||||||
domain?: string;
|
domain?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export const useVisitsQuery = (): [VisitsFiltering, UpdateFiltering] => {
|
||||||
domain,
|
domain,
|
||||||
filtering: {
|
filtering: {
|
||||||
dateRange: startDate != null || endDate != null ? datesToDateRange(startDate, endDate) : undefined,
|
dateRange: startDate != null || endDate != null ? datesToDateRange(startDate, endDate) : undefined,
|
||||||
visitsFilter: { orphanVisitsType, excludeBots: excludeBots === 'true' },
|
visitsFilter: { orphanVisitsType, excludeBots: !isNil(excludeBots) ? excludeBots === 'true' : undefined },
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
@ -49,7 +49,7 @@ export const useVisitsQuery = (): [VisitsFiltering, UpdateFiltering] => {
|
||||||
const query: VisitsQuery = {
|
const query: VisitsQuery = {
|
||||||
startDate: (dateRange?.startDate && formatIsoDate(dateRange.startDate)) || '',
|
startDate: (dateRange?.startDate && formatIsoDate(dateRange.startDate)) || '',
|
||||||
endDate: (dateRange?.endDate && formatIsoDate(dateRange.endDate)) || '',
|
endDate: (dateRange?.endDate && formatIsoDate(dateRange.endDate)) || '',
|
||||||
excludeBots: visitsFilter.excludeBots ? 'true' : undefined,
|
excludeBots: visitsFilter.excludeBots ? 'true' : 'false',
|
||||||
orphanVisitsType: visitsFilter.orphanVisitsType,
|
orphanVisitsType: visitsFilter.orphanVisitsType,
|
||||||
domain: theDomain,
|
domain: theDomain,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue