mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
38 lines
937 B
C#
38 lines
937 B
C#
using Microsoft.Identity.Client;
|
|
using Remotely.Shared.Enums;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Remotely.Server.Services;
|
|
|
|
public interface IThemeProvider
|
|
{
|
|
Task<Theme> GetEffectiveTheme();
|
|
}
|
|
|
|
public class ThemeProvider : IThemeProvider
|
|
{
|
|
private readonly IAuthService _authService;
|
|
private readonly IDataService _dataService;
|
|
|
|
public ThemeProvider(IAuthService authService, IDataService dataService)
|
|
{
|
|
_authService = authService;
|
|
_dataService = dataService;
|
|
}
|
|
|
|
public async Task<Theme> GetEffectiveTheme()
|
|
{
|
|
var settings = await _dataService.GetSettings();
|
|
if (await _authService.IsAuthenticated())
|
|
{
|
|
var userResult = await _authService.GetUser();
|
|
if (userResult.IsSuccess)
|
|
{
|
|
return userResult.Value.UserOptions?.Theme ?? settings.Theme;
|
|
}
|
|
}
|
|
|
|
return settings.Theme;
|
|
}
|
|
}
|