Fix couple potential crash issues due to unsupported APIs.
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.WinUI.Notifications;
|
||||
using Serilog;
|
||||
using Windows.Data.Xml.Dom;
|
||||
using Windows.UI.Notifications;
|
||||
using Wino.Core.Domain;
|
||||
@@ -38,6 +39,8 @@ namespace Wino.Core.UWP.Services
|
||||
{
|
||||
var mailCount = downloadedMailItems.Count();
|
||||
|
||||
try
|
||||
{
|
||||
// If there are more than 3 mails, just display 1 general toast.
|
||||
if (mailCount > 3)
|
||||
{
|
||||
@@ -70,8 +73,8 @@ namespace Wino.Core.UWP.Services
|
||||
|
||||
foreach (var mailItem in validItems)
|
||||
{
|
||||
//if (mailItem.IsRead)
|
||||
// continue;
|
||||
if (mailItem.IsRead)
|
||||
continue;
|
||||
|
||||
var builder = new ToastContentBuilder();
|
||||
builder.SetToastScenario(ToastScenario.Default);
|
||||
@@ -117,6 +120,11 @@ namespace Wino.Core.UWP.Services
|
||||
await UpdateTaskbarIconBadgeAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Failed to create notifications.");
|
||||
}
|
||||
}
|
||||
|
||||
private ToastButton GetDismissButton()
|
||||
=> new ToastButton()
|
||||
@@ -142,10 +150,10 @@ namespace Wino.Core.UWP.Services
|
||||
public async Task UpdateTaskbarIconBadgeAsync()
|
||||
{
|
||||
int totalUnreadCount = 0;
|
||||
var badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
|
||||
|
||||
try
|
||||
{
|
||||
var badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
|
||||
var accounts = await _accountService.GetAccountsAsync();
|
||||
|
||||
foreach (var account in accounts)
|
||||
@@ -178,11 +186,9 @@ namespace Wino.Core.UWP.Services
|
||||
else
|
||||
badgeUpdater.Clear();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
// TODO: Log exceptions.
|
||||
|
||||
badgeUpdater.Clear();
|
||||
Log.Error(ex, "Error while updating taskbar badge.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user