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