Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Cache options

Blue Moused7532e8a5647
diff --git a/web/app/ui/TimezonePicker.tsx b/web/app/ui/TimezonePicker.tsx
index 3ae89edb8..31e27282e 100644
--- a/web/app/ui/TimezonePicker.tsx
+++ b/web/app/ui/TimezonePicker.tsx
@@ -1,3 +1,5 @@
+import { useMemo } from 'react'
+
import _find from 'lodash/find'
import _includes from 'lodash/includes'
import _reduce from 'lodash/reduce'
@@ -110,7 +112,16 @@ interface TimezoneSelectProps {
}
const TimezoneSelect = ({ value, onChange }: TimezoneSelectProps) => {
- const options = buildOptions()
+ const now = new Date()
+ const optionsCacheKey = new Date(
+ now.getFullYear(),
+ now.getMonth(),
+ now.getDate(),
+ ).getTime()
+ const options = useMemo(
+ () => buildOptions(new Date(optionsCacheKey + 12 * 60 * 60 * 1000)),
+ [optionsCacheKey],
+ )
const labelExtractor = (option: TimezoneOption | null | undefined) =>
option?.label
const keyExtractor = (option: TimezoneOption) => option.value