fix: prevent blank screen crash when clearing timezone search field

This commit is contained in:
Aicha Lassoued committed 2026-04-26 18:25:53 +01:00
1 parent 29f1041cc3
commit 66418bf591
3 files changed
+10 -5

No files matched your search

+3 -1
View File
@@ -89,7 +89,9 @@ const uiSlice = createSlice({
},
setTimezone: (state, action: PayloadAction<{ timezone: string }>) => {
state.timezone = action.payload.timezone;
if (action.payload.timezone) {
state.timezone = action.payload.timezone;
}
},
setLanguage: (state, action: PayloadAction<string>) => {
state.language = action.payload;
+2 -2
View File
@@ -127,8 +127,8 @@ export const SettingsPage = () => {
timezoneOptions.find((tz) => tz.id === selectedTimezoneId) ?? null;
const handleTimezoneChange = (newValue: Timezone | null) => {
const newId = newValue?.id ?? "";
dispatch(setTimezone({ timezone: newId }));
if (!newValue?.id) return;
dispatch(setTimezone({ timezone: newValue.id }));
};
const handleModeChange = (e: SelectChangeEvent<ThemeMode>) => {
+5 -2
View File
@@ -19,8 +19,11 @@ export const formatDateWithTz = (timestamp: string, format: string, timezone: st
if (!timestamp) {
return "Unknown time";
}
const formattedDate = dayjs(timestamp).tz(timezone).format(format);
return formattedDate;
try {
return dayjs(timestamp).tz(timezone).format(format);
} catch {
return dayjs(timestamp).utc().format(format);
}
};
export const tickDateFormatLookup = (range: string) => {