diff --git a/src/DesktopClient/PresenceLight/MainWindow.xaml.cs b/src/DesktopClient/PresenceLight/MainWindow.xaml.cs
index 8d75a084..8acdd8a4 100644
--- a/src/DesktopClient/PresenceLight/MainWindow.xaml.cs
+++ b/src/DesktopClient/PresenceLight/MainWindow.xaml.cs
@@ -490,7 +490,7 @@ private async Task InteractWithLights()
{
if (_appState.User == null || string.IsNullOrEmpty(_appState.User.DisplayName))
{
- var (profile, presence) = await _mediator.Send(new Core.GraphServices.GetProfileAndPresenceCommand());
+ var (profile, presence, email) = await _mediator.Send(new Core.GraphServices.GetProfileAndPresenceCommand());
var photo = await GetPhoto();
@@ -506,6 +506,8 @@ private async Task InteractWithLights()
MapUI(presence);
_appState.SetUserInfo(profile, presence, $"data:image/gif;base64,{Convert.ToBase64String(photo)}");
}
+
+ _appState.Email = email;
}
await Task.Delay(Convert.ToInt32(_appState.Config.LightSettings.PollingInterval * 1000));
diff --git a/src/PresenceLight.Core/Configuration/AppState.cs b/src/PresenceLight.Core/Configuration/AppState.cs
index 334669eb..b4ef1cf0 100644
--- a/src/PresenceLight.Core/Configuration/AppState.cs
+++ b/src/PresenceLight.Core/Configuration/AppState.cs
@@ -115,6 +115,11 @@ public class AppState
///
public BaseConfig Config { get; set; } = new BaseConfig();
+ ///
+ /// Gets or sets the user's email.
+ ///
+ public string Email { get; set; }
+
///
/// Sets the configuration.
///
@@ -135,6 +140,7 @@ public void SetUserInfo(User? user, Presence? presence, string? photo = null)
User = user;
Presence = presence;
ProfileImage = photo;
+ Email = user?.Mail;
NotifyStateChanged();
}
diff --git a/src/PresenceLight.Core/GraphServices/GetProfileAndPresenceHandler.cs b/src/PresenceLight.Core/GraphServices/GetProfileAndPresenceHandler.cs
new file mode 100644
index 00000000..f2b921a4
--- /dev/null
+++ b/src/PresenceLight.Core/GraphServices/GetProfileAndPresenceHandler.cs
@@ -0,0 +1,24 @@
+using MediatR;
+using Microsoft.Graph.Models;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace PresenceLight.Core.GraphServices
+{
+ internal class GetProfileAndPresenceHandler : IRequestHandler
+ {
+ GraphWrapper _graph;
+
+ public GetProfileAndPresenceHandler(GraphWrapper graph)
+ {
+ _graph = graph;
+ }
+
+ public async Task<(User User, Presence Presence, string Email)> Handle(GetProfileAndPresenceCommand command, CancellationToken cancellationToken)
+ {
+ var (user, presence) = await _graph.GetProfileAndPresence(cancellationToken);
+ var email = user.Mail;
+ return (user, presence, email);
+ }
+ }
+}
diff --git a/src/PresenceLight.Razor/Components/Shared/LoginDisplay.razor b/src/PresenceLight.Razor/Components/Shared/LoginDisplay.razor
index 23211469..7c9e638a 100644
--- a/src/PresenceLight.Razor/Components/Shared/LoginDisplay.razor
+++ b/src/PresenceLight.Razor/Components/Shared/LoginDisplay.razor
@@ -7,7 +7,7 @@
{
- Hello, @appState.User.DisplayName!
+ Hello, @appState.User.DisplayName! (@appState.Email)
@@ -80,4 +80,4 @@ else
{
InvokeAsync(StateHasChanged);
}
-}
\ No newline at end of file
+}