Fix crash in getBackgroundColor
This commit is contained in:
parent
4d2910d696
commit
aabcc71c3c
1 changed files with 16 additions and 14 deletions
30
app/main.ts
30
app/main.ts
|
@ -319,30 +319,32 @@ type GetThemeSettingOptionsType = Readonly<{
|
||||||
async function getThemeSetting({
|
async function getThemeSetting({
|
||||||
ephemeralOnly = false,
|
ephemeralOnly = false,
|
||||||
}: GetThemeSettingOptionsType = {}): Promise<ThemeSettingType> {
|
}: GetThemeSettingOptionsType = {}): Promise<ThemeSettingType> {
|
||||||
|
let result: unknown;
|
||||||
|
|
||||||
const fastValue = ephemeralConfig.get('theme-setting');
|
const fastValue = ephemeralConfig.get('theme-setting');
|
||||||
if (fastValue !== undefined) {
|
if (fastValue !== undefined) {
|
||||||
getLogger().info('got fast theme-setting value', fastValue);
|
getLogger().info('got fast theme-setting value', fastValue);
|
||||||
return fastValue as ThemeSettingType;
|
result = fastValue;
|
||||||
}
|
} else if (ephemeralOnly) {
|
||||||
|
|
||||||
if (ephemeralOnly) {
|
|
||||||
return 'system';
|
return 'system';
|
||||||
}
|
} else {
|
||||||
|
const json = await sql.sqlCall('getItemById', 'theme-setting');
|
||||||
|
|
||||||
const json = await sql.sqlCall('getItemById', 'theme-setting');
|
result = json?.value;
|
||||||
|
}
|
||||||
|
|
||||||
// Default to `system` if setting doesn't exist or is invalid
|
// Default to `system` if setting doesn't exist or is invalid
|
||||||
const setting: unknown = json?.value;
|
const validatedResult =
|
||||||
const slowValue =
|
result === 'light' || result === 'dark' || result === 'system'
|
||||||
setting === 'light' || setting === 'dark' || setting === 'system'
|
? result
|
||||||
? setting
|
|
||||||
: 'system';
|
: 'system';
|
||||||
|
|
||||||
ephemeralConfig.set('theme-setting', slowValue);
|
if (fastValue !== validatedResult) {
|
||||||
|
ephemeralConfig.set('theme-setting', validatedResult);
|
||||||
|
getLogger().info('got slow theme-setting value', result);
|
||||||
|
}
|
||||||
|
|
||||||
getLogger().info('got slow theme-setting value', slowValue);
|
return validatedResult;
|
||||||
|
|
||||||
return slowValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getResolvedThemeSetting(
|
async function getResolvedThemeSetting(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue