📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
removing the projects cache when timezone preference changes
Blue Mouseecbbf37c56a4
diff --git a/src/pages/UserSettings/UserSettings.container.jsx b/src/pages/UserSettings/UserSettings.container.jsxindex af63ca04c..3b35cb4f4 100644--- a/src/pages/UserSettings/UserSettings.container.jsx+++ b/src/pages/UserSettings/UserSettings.container.jsx@@ -13,6 +13,7 @@ import { withAuthentication, auth } from 'hoc/protected'import { authActions } from 'redux/actions/auth'import { errorsActions } from 'redux/actions/errors'import { alertsActions } from 'redux/actions/alerts'+import UIActions from 'redux/actions/ui'import { getCookie, setCookie } from 'utils/cookie'import { confirmEmail, exportUserData } from 'api'import routes from 'routes'@@ -52,6 +53,10 @@ const UserSettingsContainer = () => {}}+ const onDeleteProjectCache = () => {+ dispatch(UIActions.deleteProjectCache())+ }+const onSubmit = (data) => {delete data.repeatfor (let key in data) {@@ -97,6 +102,7 @@ const UserSettingsContainer = () => {onExport={onExport}onSubmit={onSubmit}onEmailConfirm={onEmailConfirm}+ onDeleteProjectCache={onDeleteProjectCache}/>)}diff --git a/src/pages/UserSettings/UserSettings.jsx b/src/pages/UserSettings/UserSettings.jsxindex c132c3c07..77d125e9b 100644--- a/src/pages/UserSettings/UserSettings.jsx+++ b/src/pages/UserSettings/UserSettings.jsx@@ -8,7 +8,7 @@ import _findIndex from 'lodash/findIndex'import _map from 'lodash/map'import { MailIcon } from '@heroicons/react/outline'-import { reportFrequencies } from 'redux/constants'+import { reportFrequencies, DEFAULT_TIMEZONE } from 'redux/constants'import Title from 'components/Title'import Input from 'ui/Input'import Button from 'ui/Button'@@ -19,10 +19,8 @@ import {isValidEmail, isValidPassword, MIN_PASSWORD_CHARS,} from 'utils/validator'-const DEFAULT_TIMEZONE = 'Etc/GMT'-const UserSettings = ({- onDelete, onExport, onSubmit, onEmailConfirm, t,+ onDelete, onExport, onSubmit, onEmailConfirm, onDeleteProjectCache, t,}) => {const { user } = useSelector(state => state.auth)@@ -32,6 +30,7 @@ const UserSettings = ({repeat: '',})const [timezone, setTimezone] = useState(user.timezone || DEFAULT_TIMEZONE)+ const [timezoneChanged, setTimezoneChanged] = useState(false)const [reportFrequency, setReportFrequency] = useState(user.reportFrequency)const [validated, setValidated] = useState(false)const [errors, setErrors] = useState({})@@ -45,6 +44,11 @@ const UserSettings = ({validate()}, [form]) // eslint-disable-line+ const _setTimezone = (value) => {+ setTimezoneChanged(true)+ setTimezone(value)+ }+const handleInput = event => {const t = event.targetconst value = t.type === 'checkbox' ? t.checked : t.value@@ -60,6 +64,11 @@ const UserSettings = ({e.stopPropagation()setBeenSubmitted(true)+ // if the timezone updates, we need to delete all project cache to refetch it with the new timezone setting afterwards+ if (timezoneChanged) {+ onDeleteProjectCache()+ }+if (validated) {onSubmit({...form,@@ -150,7 +159,7 @@ const UserSettings = ({<div><TimezonePickervalue={timezone}- onChange={setTimezone}+ onChange={_setTimezone}/></div></div>