Fixed visits query being lost when switching between sub-sections

This commit is contained in:
Alejandro Celaya 2022-12-17 09:28:42 +01:00
parent f911f78c95
commit b2b6b3af18
2 changed files with 3 additions and 8 deletions

View file

@ -55,7 +55,6 @@ export const ShortUrlVisits = ({ exportVisits }: ReportExporter) => boundToMercu
getVisits={loadVisits} getVisits={loadVisits}
cancelGetVisits={cancelGetShortUrlVisits} cancelGetVisits={cancelGetShortUrlVisits}
visitsInfo={shortUrlVisits} visitsInfo={shortUrlVisits}
domain={domain}
settings={settings} settings={settings}
exportCsv={exportCsv} exportCsv={exportCsv}
selectedServer={selectedServer} selectedServer={selectedServer}

View file

@ -4,7 +4,7 @@ import { Button, Progress, Row } from 'reactstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCalendarAlt, faMapMarkedAlt, faList, faChartPie } from '@fortawesome/free-solid-svg-icons'; import { faCalendarAlt, faMapMarkedAlt, faList, faChartPie } from '@fortawesome/free-solid-svg-icons';
import { IconDefinition } from '@fortawesome/fontawesome-common-types'; import { IconDefinition } from '@fortawesome/fontawesome-common-types';
import { Route, Routes, Navigate } from 'react-router-dom'; import { Route, Routes, Navigate, useLocation } from 'react-router-dom';
import classNames from 'classnames'; import classNames from 'classnames';
import { DateRangeSelector } from '../utils/dates/DateRangeSelector'; import { DateRangeSelector } from '../utils/dates/DateRangeSelector';
import { Message } from '../utils/Message'; import { Message } from '../utils/Message';
@ -35,7 +35,6 @@ export type VisitsStatsProps = PropsWithChildren<{
settings: Settings; settings: Settings;
selectedServer: SelectedServer; selectedServer: SelectedServer;
cancelGetVisits: () => void; cancelGetVisits: () => void;
domain?: string;
exportCsv: (visits: NormalizedVisit[]) => void; exportCsv: (visits: NormalizedVisit[]) => void;
isOrphanVisits?: boolean; isOrphanVisits?: boolean;
}>; }>;
@ -62,7 +61,6 @@ export const VisitsStats: FC<VisitsStatsProps> = ({
visitsInfo, visitsInfo,
getVisits, getVisits,
cancelGetVisits, cancelGetVisits,
domain,
settings, settings,
exportCsv, exportCsv,
selectedServer, selectedServer,
@ -86,11 +84,9 @@ export const VisitsStats: FC<VisitsStatsProps> = ({
const [highlightedLabel, setHighlightedLabel] = useState<string | undefined>(); const [highlightedLabel, setHighlightedLabel] = useState<string | undefined>();
const botsSupported = supportsBotVisits(selectedServer); const botsSupported = supportsBotVisits(selectedServer);
const isFirstLoad = useRef(true); const isFirstLoad = useRef(true);
const { search } = useLocation();
const buildSectionUrl = (subPath?: string) => { const buildSectionUrl = (subPath?: string) => (!subPath ? search : `${subPath}${search}`);
const query = domain ? `?domain=${domain}` : '';
return !subPath ? `${query}` : `${subPath}${query}`;
};
const normalizedVisits = useMemo(() => normalizeVisits(visits), [visits]); const normalizedVisits = useMemo(() => normalizeVisits(visits), [visits]);
const { os, browsers, referrers, countries, cities, citiesForMap, visitedUrls } = useMemo( const { os, browsers, referrers, countries, cities, citiesForMap, visitedUrls } = useMemo(
() => processStatsFromVisits(normalizedVisits), () => processStatsFromVisits(normalizedVisits),