mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 09:45:04 +01:00
Fixed bug in global date range setting.
This commit is contained in:
parent
9eca86a4fc
commit
7d25fd6876
@ -30,7 +30,8 @@ export default function ProfileSettings() {
|
||||
}
|
||||
|
||||
function handleDateChange(values) {
|
||||
setItem(`umami.date-range`, values);
|
||||
const { value } = values;
|
||||
setItem(`umami.date-range`, value === 'custom' ? values : value);
|
||||
dispatch(setDateRange(0, values));
|
||||
}
|
||||
|
||||
|
@ -5,14 +5,20 @@ import { getItem } from 'lib/web';
|
||||
|
||||
export default function useDateRange(websiteId, defaultDateRange = '24hour') {
|
||||
const globalDefault = getItem('umami.date-range');
|
||||
let globalDateRange;
|
||||
|
||||
if (globalDefault) {
|
||||
globalDefault.startDate = parseISO(globalDefault.startDate);
|
||||
globalDefault.endDate = parseISO(globalDefault.endDate);
|
||||
if (typeof globalDefault === 'string') {
|
||||
globalDateRange = getDateRange(globalDefault);
|
||||
} else {
|
||||
globalDateRange = {
|
||||
...globalDefault,
|
||||
startDate: parseISO(globalDefault.startDate),
|
||||
endDate: parseISO(globalDefault.endDate),
|
||||
};
|
||||
}
|
||||
|
||||
return useSelector(
|
||||
state =>
|
||||
state.websites[websiteId]?.dateRange || globalDefault || getDateRange(defaultDateRange),
|
||||
state.websites[websiteId]?.dateRange || globalDateRange || getDateRange(defaultDateRange),
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user