Stream custom live channels using your own media
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

33 lines
1.3 KiB

using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Repositories;
namespace ErsatzTV.Application.Configuration;
public class GetUiSettingsHandler(IConfigElementRepository configElementRepository)
: IRequestHandler<GetUiSettings, UiSettingsViewModel>
{
public async Task<UiSettingsViewModel> Handle(GetUiSettings request, CancellationToken cancellationToken)
{
Option<ThemeMode> pagesThemeMode = await configElementRepository.GetValue<ThemeMode>(
ConfigElementKey.PagesThemeMode,
cancellationToken);
// fall back to the legacy dark mode flag for installs that predate the theme mode setting
Option<bool> pagesIsDarkMode = await configElementRepository.GetValue<bool>(
ConfigElementKey.PagesIsDarkMode,
cancellationToken);
Option<string> pagesLanguage = await configElementRepository.GetValue<string>(
ConfigElementKey.PagesLanguage,
cancellationToken);
return new UiSettingsViewModel
{
ThemeMode = pagesThemeMode.IfNone(
() => pagesIsDarkMode.Match(
isDarkMode => isDarkMode ? ThemeMode.Dark : ThemeMode.Light,
() => ThemeMode.Dark)),
Language = await pagesLanguage.IfNoneAsync("en")
};
}
}