diff --git a/CHANGELOG.md b/CHANGELOG.md index ce34677b..e29a5871 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed * [#534](https://github.com/shlinkio/shlink-web-client/pull/534) Updated axios. * [#538](https://github.com/shlinkio/shlink-web-client/pull/538) Switched to the `-` notation in `orderBy` param for short URLs list, in preparation for Shlink v3.0.0 +* Fixed typo in identifier for "Last 180 days" interval. + + If that was your default interval, you will see now "All visits" is selected instead. You will need to go to settings page and change it again to "Last 180 days". ### Deprecated * *Nothing* diff --git a/src/utils/dates/DateRangeSelector.tsx b/src/utils/dates/DateRangeSelector.tsx index 3e9d10fe..c9d7dd1a 100644 --- a/src/utils/dates/DateRangeSelector.tsx +++ b/src/utils/dates/DateRangeSelector.tsx @@ -40,11 +40,10 @@ export const DateRangeSelector = ( }; updatable && useEffectExceptFirstTime(() => { - if (rangeIsInterval(initialDateRange)) { - updateInterval(initialDateRange); - } else if (initialDateRange) { - updateDateRange(initialDateRange); - } + const isDateInterval = rangeIsInterval(initialDateRange); + + isDateInterval && updateInterval(initialDateRange); + initialDateRange && !isDateInterval && updateDateRange(initialDateRange); }, [ initialDateRange ]); return ( diff --git a/src/visits/OrphanVisits.tsx b/src/visits/OrphanVisits.tsx index f30f5557..af4dc7a4 100644 --- a/src/visits/OrphanVisits.tsx +++ b/src/visits/OrphanVisits.tsx @@ -10,7 +10,11 @@ import { CommonVisitsProps } from './types/CommonVisitsProps'; import { toApiParams } from './types/helpers'; export interface OrphanVisitsProps extends CommonVisitsProps, RouteComponentProps { - getOrphanVisits: (params?: ShlinkVisitsParams, orphanVisitsType?: OrphanVisitType, doFallbackRange?: boolean) => void; + getOrphanVisits: ( + params?: ShlinkVisitsParams, + orphanVisitsType?: OrphanVisitType, + doIntervalFallback?: boolean, + ) => void; orphanVisits: VisitsInfo; cancelGetOrphanVisits: () => void; } @@ -25,8 +29,8 @@ export const OrphanVisits = ({ exportVisits }: VisitsExporter) => boundToMercure selectedServer, }: OrphanVisitsProps) => { const exportCsv = (visits: NormalizedVisit[]) => exportVisits('orphan_visits.csv', visits); - const loadVisits = (params: VisitsParams, doFallbackRange?: boolean) => - getOrphanVisits(toApiParams(params), params.filter?.orphanVisitsType, doFallbackRange); + const loadVisits = (params: VisitsParams, doIntervalFallback?: boolean) => + getOrphanVisits(toApiParams(params), params.filter?.orphanVisitsType, doIntervalFallback); return ( { - getShortUrlVisits: (shortCode: string, query?: ShlinkVisitsParams, doFallbackRange?: boolean) => void; + getShortUrlVisits: (shortCode: string, query?: ShlinkVisitsParams, doIntervalFallback?: boolean) => void; shortUrlVisits: ShortUrlVisitsState; getShortUrlDetail: Function; shortUrlDetail: ShortUrlDetail; @@ -35,8 +35,8 @@ const ShortUrlVisits = ({ exportVisits }: VisitsExporter) => boundToMercureHub(( }: ShortUrlVisitsProps) => { const { shortCode } = params; const { domain } = parseQuery<{ domain?: string }>(search); - const loadVisits = (params: VisitsParams, doFallbackRange?: boolean) => - getShortUrlVisits(shortCode, { ...toApiParams(params), domain }, doFallbackRange); + const loadVisits = (params: VisitsParams, doIntervalFallback?: boolean) => + getShortUrlVisits(shortCode, { ...toApiParams(params), domain }, doIntervalFallback); const exportCsv = (visits: NormalizedVisit[]) => exportVisits( `short-url_${shortUrlDetail.shortUrl?.shortUrl.replace(/https?:\/\//g, '')}_visits.csv`, visits, diff --git a/src/visits/TagVisits.tsx b/src/visits/TagVisits.tsx index fefbaa7e..702bd837 100644 --- a/src/visits/TagVisits.tsx +++ b/src/visits/TagVisits.tsx @@ -12,7 +12,7 @@ import { CommonVisitsProps } from './types/CommonVisitsProps'; import { toApiParams } from './types/helpers'; export interface TagVisitsProps extends CommonVisitsProps, RouteComponentProps<{ tag: string }> { - getTagVisits: (tag: string, query?: ShlinkVisitsParams, doFallbackRange?: boolean) => void; + getTagVisits: (tag: string, query?: ShlinkVisitsParams, doIntervalFallback?: boolean) => void; tagVisits: TagVisitsState; cancelGetTagVisits: () => void; } @@ -27,8 +27,8 @@ const TagVisits = (colorGenerator: ColorGenerator, { exportVisits }: VisitsExpor selectedServer, }: TagVisitsProps) => { const { tag } = params; - const loadVisits = (params: ShlinkVisitsParams, doFallbackRange?: boolean) => - getTagVisits(tag, toApiParams(params), doFallbackRange); + const loadVisits = (params: ShlinkVisitsParams, doIntervalFallback?: boolean) => + getTagVisits(tag, toApiParams(params), doIntervalFallback); const exportCsv = (visits: NormalizedVisit[]) => exportVisits(`tag_${tag}_visits.csv`, visits); return ( diff --git a/src/visits/VisitsStats.tsx b/src/visits/VisitsStats.tsx index e136383e..8818ada7 100644 --- a/src/visits/VisitsStats.tsx +++ b/src/visits/VisitsStats.tsx @@ -28,7 +28,7 @@ import { SortableBarChartCard } from './charts/SortableBarChartCard'; import './VisitsStats.scss'; export interface VisitsStatsProps { - getVisits: (params: VisitsParams, doFallbackRange?: boolean) => void; + getVisits: (params: VisitsParams, doIntervalFallback?: boolean) => void; visitsInfo: VisitsInfo; settings: Settings; selectedServer: SelectedServer; diff --git a/src/visits/reducers/common.ts b/src/visits/reducers/common.ts index 174b36df..0d9ecff6 100644 --- a/src/visits/reducers/common.ts +++ b/src/visits/reducers/common.ts @@ -86,10 +86,10 @@ export const getVisitsWithLoader = async & { visits: V }; export const lastVisitLoaderForLoader = ( - doFallbackRange: boolean, + doIntervalFallback: boolean, loader: (params: ShlinkVisitsParams) => Promise, ): LastVisitLoader => { - if (!doFallbackRange) { + if (!doIntervalFallback) { return async () => Promise.resolve(undefined); } diff --git a/src/visits/reducers/orphanVisits.ts b/src/visits/reducers/orphanVisits.ts index f212f323..bcb06d8a 100644 --- a/src/visits/reducers/orphanVisits.ts +++ b/src/visits/reducers/orphanVisits.ts @@ -72,7 +72,7 @@ const matchesType = (visit: OrphanVisit, orphanVisitsType?: OrphanVisitType) => export const getOrphanVisits = (buildShlinkApiClient: ShlinkApiClientBuilder) => ( query: ShlinkVisitsParams = {}, orphanVisitsType?: OrphanVisitType, - doFallbackRange = false, + doIntervalFallback = false, ) => async (dispatch: Dispatch, getState: GetState) => { const { getOrphanVisits } = buildShlinkApiClient(getState); const visitsLoader = async (page: number, itemsPerPage: number) => getOrphanVisits({ ...query, page, itemsPerPage }) @@ -81,7 +81,7 @@ export const getOrphanVisits = (buildShlinkApiClient: ShlinkApiClientBuilder) => return { ...result, data: visits }; }); - const lastVisitLoader = lastVisitLoaderForLoader(doFallbackRange, getOrphanVisits); + const lastVisitLoader = lastVisitLoaderForLoader(doIntervalFallback, getOrphanVisits); const shouldCancel = () => getState().orphanVisits.cancelLoad; const extraFinishActionData: Partial = { query }; const actionMap = { diff --git a/src/visits/reducers/shortUrlVisits.ts b/src/visits/reducers/shortUrlVisits.ts index 7d5daa17..9b5cd352 100644 --- a/src/visits/reducers/shortUrlVisits.ts +++ b/src/visits/reducers/shortUrlVisits.ts @@ -78,7 +78,7 @@ export default buildReducer({ export const getShortUrlVisits = (buildShlinkApiClient: ShlinkApiClientBuilder) => ( shortCode: string, query: ShlinkVisitsParams = {}, - doFallbackRange = false, + doIntervalFallback = false, ) => async (dispatch: Dispatch, getState: GetState) => { const { getShortUrlVisits } = buildShlinkApiClient(getState); const visitsLoader = async (page: number, itemsPerPage: number) => getShortUrlVisits( @@ -86,7 +86,7 @@ export const getShortUrlVisits = (buildShlinkApiClient: ShlinkApiClientBuilder) { ...query, page, itemsPerPage }, ); const lastVisitLoader = lastVisitLoaderForLoader( - doFallbackRange, + doIntervalFallback, async (params) => getShortUrlVisits(shortCode, { ...params, domain: query.domain }), ); const shouldCancel = () => getState().shortUrlVisits.cancelLoad; diff --git a/src/visits/reducers/tagVisits.ts b/src/visits/reducers/tagVisits.ts index ff96f90b..272bd241 100644 --- a/src/visits/reducers/tagVisits.ts +++ b/src/visits/reducers/tagVisits.ts @@ -67,14 +67,14 @@ export default buildReducer({ export const getTagVisits = (buildShlinkApiClient: ShlinkApiClientBuilder) => ( tag: string, query: ShlinkVisitsParams = {}, - doFallbackRange = false, + doIntervalFallback = false, ) => async (dispatch: Dispatch, getState: GetState) => { const { getTagVisits } = buildShlinkApiClient(getState); const visitsLoader = async (page: number, itemsPerPage: number) => getTagVisits( tag, { ...query, page, itemsPerPage }, ); - const lastVisitLoader = lastVisitLoaderForLoader(doFallbackRange, async (params) => getTagVisits(tag, params)); + const lastVisitLoader = lastVisitLoaderForLoader(doIntervalFallback, async (params) => getTagVisits(tag, params)); const shouldCancel = () => getState().tagVisits.cancelLoad; const extraFinishActionData: Partial = { tag, query }; const actionMap = {