From 52923ed35b6bb9590130c0fedfbf77ec08c12da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Mon, 26 Aug 2024 22:09:00 +0200 Subject: [PATCH] Bump some more nugets, remove redundant events, and fix Outlook profile sync permission issue. --- Wino.Core.Domain/Interfaces/IThemeService.cs | 1 - Wino.Core.Domain/Wino.Core.Domain.csproj | 2 +- Wino.Core.UWP/Services/ThemeService.cs | 1 - Wino.Core.UWP/Wino.Core.UWP.csproj | 2 +- .../Authenticators/GmailAuthenticator.cs | 2 -- .../Authenticators/OutlookAuthenticator.cs | 11 +++++++- .../Synchronizers/OutlookSynchronizer.cs | 25 +++++++++++++++---- Wino.Core/Wino.Core.csproj | 10 ++++---- .../PersonalizationPageViewModel.cs | 13 ---------- .../Wino.Mail.ViewModels.csproj | 4 +-- Wino.Mail/Wino.Mail.csproj | 10 ++++---- 11 files changed, 44 insertions(+), 37 deletions(-) diff --git a/Wino.Core.Domain/Interfaces/IThemeService.cs b/Wino.Core.Domain/Interfaces/IThemeService.cs index 57c3f471..86496fca 100644 --- a/Wino.Core.Domain/Interfaces/IThemeService.cs +++ b/Wino.Core.Domain/Interfaces/IThemeService.cs @@ -9,7 +9,6 @@ namespace Wino.Core.Domain.Interfaces public interface IThemeService : IInitializeAsync { event EventHandler ElementThemeChanged; - event EventHandler AccentColorChangedBySystem; event EventHandler AccentColorChanged; Task> GetAvailableThemesAsync(); diff --git a/Wino.Core.Domain/Wino.Core.Domain.csproj b/Wino.Core.Domain/Wino.Core.Domain.csproj index 64fe85b1..20b3ac1c 100644 --- a/Wino.Core.Domain/Wino.Core.Domain.csproj +++ b/Wino.Core.Domain/Wino.Core.Domain.csproj @@ -62,7 +62,7 @@ - + diff --git a/Wino.Core.UWP/Services/ThemeService.cs b/Wino.Core.UWP/Services/ThemeService.cs index c5166db9..d32de95b 100644 --- a/Wino.Core.UWP/Services/ThemeService.cs +++ b/Wino.Core.UWP/Services/ThemeService.cs @@ -46,7 +46,6 @@ namespace Wino.Services public event EventHandler ElementThemeChanged; public event EventHandler AccentColorChanged; - public event EventHandler AccentColorChangedBySystem; private const string AccentColorKey = nameof(AccentColorKey); private const string CurrentApplicationThemeKey = nameof(CurrentApplicationThemeKey); diff --git a/Wino.Core.UWP/Wino.Core.UWP.csproj b/Wino.Core.UWP/Wino.Core.UWP.csproj index ac9b9bf9..a2fbcd9f 100644 --- a/Wino.Core.UWP/Wino.Core.UWP.csproj +++ b/Wino.Core.UWP/Wino.Core.UWP.csproj @@ -112,7 +112,7 @@ 7.1.2 - 5.0.4 + 5.0.5 6.2.14 diff --git a/Wino.Core/Authenticators/GmailAuthenticator.cs b/Wino.Core/Authenticators/GmailAuthenticator.cs index 7bcc915f..efb646f8 100644 --- a/Wino.Core/Authenticators/GmailAuthenticator.cs +++ b/Wino.Core/Authenticators/GmailAuthenticator.cs @@ -26,8 +26,6 @@ namespace Wino.Core.Authenticators private readonly INativeAppService _nativeAppService; - public event EventHandler InteractiveAuthenticationRequired; - public GmailAuthenticator(ITokenService tokenService, INativeAppService nativeAppService) : base(tokenService) { _nativeAppService = nativeAppService; diff --git a/Wino.Core/Authenticators/OutlookAuthenticator.cs b/Wino.Core/Authenticators/OutlookAuthenticator.cs index 4fa78378..88436598 100644 --- a/Wino.Core/Authenticators/OutlookAuthenticator.cs +++ b/Wino.Core/Authenticators/OutlookAuthenticator.cs @@ -28,7 +28,16 @@ namespace Wino.Core.Authenticators public string ClientId { get; } = "b19c2035-d740-49ff-b297-de6ec561b208"; - private readonly string[] MailScope = ["email", "mail.readwrite", "offline_access", "mail.send", "Mail.Send.Shared", "Mail.ReadWrite.Shared"]; + private readonly string[] MailScope = + [ + "email", + "mail.readwrite", + "offline_access", + "mail.send", + "Mail.Send.Shared", + "Mail.ReadWrite.Shared", + "User.Read" + ]; public override MailProviderType ProviderType => MailProviderType.Outlook; diff --git a/Wino.Core/Synchronizers/OutlookSynchronizer.cs b/Wino.Core/Synchronizers/OutlookSynchronizer.cs index 990430c8..8e9c83d8 100644 --- a/Wino.Core/Synchronizers/OutlookSynchronizer.cs +++ b/Wino.Core/Synchronizers/OutlookSynchronizer.cs @@ -12,6 +12,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Graph; using Microsoft.Graph.Models; +using Microsoft.Graph.Models.ODataErrors; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Authentication; using Microsoft.Kiota.Http.HttpClientLibrary.Middleware; @@ -473,13 +474,27 @@ namespace Wino.Core.Synchronizers /// Base64 encoded profile picture. private async Task GetUserProfilePictureAsync() { - var photoStream = await _graphClient.Me.Photos["48x48"].Content.GetAsync(); + try + { + var photoStream = await _graphClient.Me.Photos["48x48"].Content.GetAsync(); - using var memoryStream = new MemoryStream(); - await photoStream.CopyToAsync(memoryStream); - var byteArray = memoryStream.ToArray(); + using var memoryStream = new MemoryStream(); + await photoStream.CopyToAsync(memoryStream); + var byteArray = memoryStream.ToArray(); - return Convert.ToBase64String(byteArray); + return Convert.ToBase64String(byteArray); + } + catch (ODataError odataError) when (odataError.Error.Code == "ImageNotFound") + { + // Accounts without profile picture will throw this error. + // At this point nothing we can do. Just return empty string. + + return string.Empty; + } + catch (Exception) + { + throw; + } } /// diff --git a/Wino.Core/Wino.Core.csproj b/Wino.Core/Wino.Core.csproj index dd55c944..2cb7d3ce 100644 --- a/Wino.Core/Wino.Core.csproj +++ b/Wino.Core/Wino.Core.csproj @@ -18,7 +18,7 @@ - + all @@ -31,12 +31,12 @@ - + - + - - + + diff --git a/Wino.Mail.ViewModels/PersonalizationPageViewModel.cs b/Wino.Mail.ViewModels/PersonalizationPageViewModel.cs index 10509ee5..134d9989 100644 --- a/Wino.Mail.ViewModels/PersonalizationPageViewModel.cs +++ b/Wino.Mail.ViewModels/PersonalizationPageViewModel.cs @@ -221,21 +221,9 @@ namespace Wino.Mail.ViewModels _themeService.AccentColorChanged -= AccentColorChanged; _themeService.ElementThemeChanged -= ElementThemeChanged; - _themeService.AccentColorChangedBySystem -= AccentColorChangedBySystem; _themeService.AccentColorChanged += AccentColorChanged; _themeService.ElementThemeChanged += ElementThemeChanged; - _themeService.AccentColorChangedBySystem += AccentColorChangedBySystem; - } - - private void AccentColorChangedBySystem(object sender, string newAccentColorHex) - { - var accentInList = Colors.FirstOrDefault(a => a.IsAccentColor); - - if (accentInList != null) - { - accentInList.Hex = newAccentColorHex; - } } private void AccentColorChanged(object sender, string e) @@ -269,7 +257,6 @@ namespace Wino.Mail.ViewModels _themeService.AccentColorChanged -= AccentColorChanged; _themeService.ElementThemeChanged -= ElementThemeChanged; - _themeService.AccentColorChangedBySystem -= AccentColorChangedBySystem; if (AppThemes != null) { diff --git a/Wino.Mail.ViewModels/Wino.Mail.ViewModels.csproj b/Wino.Mail.ViewModels/Wino.Mail.ViewModels.csproj index 82c61360..405abe2b 100644 --- a/Wino.Mail.ViewModels/Wino.Mail.ViewModels.csproj +++ b/Wino.Mail.ViewModels/Wino.Mail.ViewModels.csproj @@ -12,8 +12,8 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/Wino.Mail/Wino.Mail.csproj b/Wino.Mail/Wino.Mail.csproj index 66359a9d..ee8dbb55 100644 --- a/Wino.Mail/Wino.Mail.csproj +++ b/Wino.Mail/Wino.Mail.csproj @@ -157,10 +157,10 @@ 1.2.0 - 5.0.4 + 5.0.5 - 5.0.4 + 5.0.5 8.0.0 @@ -186,16 +186,16 @@ 5.1.2 - 19.6.1 + 20.1.1 - 3.1.1 + 4.0.1 8.4.0 - 1.8.116 + 1.9.172 1.27.1