mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 02:08:57 +00:00
29 lines
778 B
TypeScript
29 lines
778 B
TypeScript
// Copyright 2022 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
import { SystemThemeType, ThemeType } from '../types/Util.std.js';
|
|
import { missingCaseError } from './missingCaseError.std.js';
|
|
|
|
export async function getThemeType(): Promise<ThemeType> {
|
|
const themeSetting = await window.Events.getThemeSetting();
|
|
|
|
if (themeSetting === 'light') {
|
|
return ThemeType.light;
|
|
}
|
|
|
|
if (themeSetting === 'dark') {
|
|
return ThemeType.dark;
|
|
}
|
|
|
|
if (themeSetting === 'system') {
|
|
if (window.systemTheme === SystemThemeType.light) {
|
|
return ThemeType.light;
|
|
}
|
|
if (window.systemTheme === SystemThemeType.dark) {
|
|
return ThemeType.dark;
|
|
}
|
|
throw missingCaseError(window.systemTheme);
|
|
}
|
|
throw missingCaseError(themeSetting);
|
|
}
|