Prevent white screen on page load
Bug introduced withff58dcc480. With18ddf46f17the "appearance" settings got moved from the local storage to the server metadata. However, the old settings still remained in the local storage, which includes a value with they key "appTheme". This was the id of the selected app theme. Withff58dcc480this key got resued for the app theme object, which leads to a type error in case the old setting is still present in the local storage.
This commit is contained in:
@@ -21,22 +21,22 @@ export const appThemes = (Object.entries(themes) as [AppThemes, TBaseTheme][]).m
|
||||
...theme,
|
||||
})) satisfies AppTheme[];
|
||||
|
||||
export const getTheme = (id: AppThemes, customThemes: Record<string, AppTheme> = {}): AppTheme => {
|
||||
try {
|
||||
const allThemes = { ...themes, ...customThemes };
|
||||
const theme = (allThemes[id as keyof typeof themes] as AppTheme) ?? themes.default;
|
||||
export const getTheme = (id: AppThemes | undefined, customThemes: Record<string, AppTheme> = {}): AppTheme => {
|
||||
// TODO - This is a workaround to fix a type error which causes a white screen.
|
||||
// It should be removed and replaced with a proper migration logic, which would then e.g., add a migration to
|
||||
// remove deprecated/outdated settings from the local storage
|
||||
const actualId = id === undefined ? 'default' : id;
|
||||
|
||||
return {
|
||||
// @ts-ignore - custom themes do not have a "getName" function
|
||||
getName: () => id,
|
||||
// @ts-ignore - app themes do not have the "id" prop by default
|
||||
id,
|
||||
...theme,
|
||||
};
|
||||
} catch (e) {
|
||||
defaultPromiseErrorHandler('getTheme')(e);
|
||||
}
|
||||
return { id, ...themes[id as keyof typeof themes] };
|
||||
const allThemes = { ...themes, ...customThemes };
|
||||
const theme = (allThemes[actualId as keyof typeof themes] as AppTheme) ?? themes.default;
|
||||
|
||||
return {
|
||||
// @ts-ignore - custom themes do not have a "getName" function
|
||||
getName: () => id,
|
||||
// @ts-ignore - app themes do not have the "id" prop by default
|
||||
id,
|
||||
...theme,
|
||||
};
|
||||
};
|
||||
|
||||
export const isThemeNameUnique = (id: string, customThemes: Record<string, AppTheme>): boolean =>
|
||||
|
||||
Reference in New Issue
Block a user