-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move GetEffectiveTheme to new themeProvider.
- Loading branch information
Showing
5 changed files
with
43 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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 IApplicationConfig _appConfig; | ||
|
||
public ThemeProvider(IAuthService authService, IApplicationConfig appConfig) | ||
{ | ||
_authService = authService; | ||
_appConfig = appConfig; | ||
} | ||
|
||
public async Task<Theme> GetEffectiveTheme() | ||
{ | ||
if (await _authService.IsAuthenticated()) | ||
{ | ||
var userResult = await _authService.GetUser(); | ||
if (userResult.IsSuccess) | ||
{ | ||
return userResult.Value.UserOptions?.Theme ?? _appConfig.Theme; | ||
} | ||
} | ||
|
||
return _appConfig.Theme; | ||
} | ||
} |