Merge pull request #3583 from ayshaL/fix/blank-screen-on-timezone
Fix: prevent blank screen crash when clearing timezone search field
This commit is contained in:
3 files changed
+10
-5
No files matched your search
@@ -89,7 +89,9 @@ const uiSlice = createSlice({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setTimezone: (state, action: PayloadAction<{ timezone: string }>) => {
|
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>) => {
|
setLanguage: (state, action: PayloadAction<string>) => {
|
||||||
state.language = action.payload;
|
state.language = action.payload;
|
||||||
|
|||||||
@@ -128,8 +128,8 @@ export const SettingsPage = () => {
|
|||||||
timezoneOptions.find((tz) => tz.id === selectedTimezoneId) ?? null;
|
timezoneOptions.find((tz) => tz.id === selectedTimezoneId) ?? null;
|
||||||
|
|
||||||
const handleTimezoneChange = (newValue: Timezone | null) => {
|
const handleTimezoneChange = (newValue: Timezone | null) => {
|
||||||
const newId = newValue?.id ?? "";
|
if (!newValue?.id) return;
|
||||||
dispatch(setTimezone({ timezone: newId }));
|
dispatch(setTimezone({ timezone: newValue.id }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleModeChange = (e: SelectChangeEvent<ThemeMode>) => {
|
const handleModeChange = (e: SelectChangeEvent<ThemeMode>) => {
|
||||||
|
|||||||
@@ -19,8 +19,11 @@ export const formatDateWithTz = (timestamp: string, format: string, timezone: st
|
|||||||
if (!timestamp) {
|
if (!timestamp) {
|
||||||
return "Unknown time";
|
return "Unknown time";
|
||||||
}
|
}
|
||||||
const formattedDate = dayjs(timestamp).tz(timezone).format(format);
|
try {
|
||||||
return formattedDate;
|
return dayjs(timestamp).tz(timezone).format(format);
|
||||||
|
} catch {
|
||||||
|
return dayjs(timestamp).utc().format(format);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const tickDateFormatLookup = (range: string) => {
|
export const tickDateFormatLookup = (range: string) => {
|
||||||
|
|||||||
Reference in new issue
Block a user