Skip to content

Commit b4a5fb1

Browse files
committed
Fix EnumFailedVersion in SpawnPushAppNotification + a bit of CodeQA
1 parent daf5270 commit b4a5fb1

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

CollapseLauncher/XAMLs/MainApp/MainPage.xaml.cs

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,8 @@ private RectInt32[] DragAreaMode_Normal
301301
get
302302
{
303303
double scaleFactor = WindowUtility.CurrentWindowMonitorScaleFactor;
304-
RectInt32[] rect = new RectInt32[2]
304+
RectInt32[] rect = new[]
305305
{
306-
307306
new RectInt32((int)(TitleBarDrag1.ActualOffset.X * scaleFactor),
308307
0,
309308
(int)(TitleBarDrag1.ActualWidth * scaleFactor),
@@ -324,7 +323,7 @@ private RectInt32[] DragAreaMode_Full
324323
Rect currentWindowPos = WindowUtility.CurrentWindowPosition;
325324
double scaleFactor = WindowUtility.CurrentWindowMonitorScaleFactor;
326325

327-
RectInt32[] rect = new RectInt32[1]
326+
RectInt32[] rect = new[]
328327
{
329328
new RectInt32(0,
330329
0,
@@ -364,7 +363,7 @@ private void ChangeTitleDragAreaInvoker_TitleBarEvent(object sender, ChangeTitle
364363
switch (e.Template)
365364
{
366365
case DragAreaTemplate.None:
367-
nonClientInputSrc.SetRegionRects(NonClientRegionKind.Passthrough, new RectInt32[]
366+
nonClientInputSrc.SetRegionRects(NonClientRegionKind.Passthrough, new[]
368367
{
369368
GetElementPos((WindowUtility.CurrentWindow as MainWindow)?.AppTitleBar)
370369
});
@@ -374,7 +373,7 @@ private void ChangeTitleDragAreaInvoker_TitleBarEvent(object sender, ChangeTitle
374373
break;
375374
case DragAreaTemplate.Default:
376375
nonClientInputSrc.ClearAllRegionRects();
377-
nonClientInputSrc.SetRegionRects(NonClientRegionKind.Passthrough, new RectInt32[]
376+
nonClientInputSrc.SetRegionRects(NonClientRegionKind.Passthrough, new[]
378377
{
379378
GetElementPos(GridBG_RegionGrid),
380379
GetElementPos(GridBG_IconGrid),
@@ -815,7 +814,7 @@ private async Task SpawnPushAppNotification()
815814
{
816815
TypedEventHandler<InfoBar, object> ClickCloseAction;
817816
if (NotificationData?.AppPush == null) return;
818-
foreach (NotificationProp Entry in NotificationData.AppPush)
817+
foreach (NotificationProp Entry in NotificationData.AppPush.ToList())
819818
{
820819
// Check for Close Action for certain MsgIds
821820
switch (Entry.MsgId)
@@ -926,25 +925,36 @@ private void SpawnAppUpdatedNotification()
926925

927926
// Create notification
928927
NotificationContent toastContent = NotificationContent.Create()
929-
.SetTitle(Lang._NotificationToast.LauncherUpdated_NotifTitle)
930-
.SetContent(
931-
string.Format(Lang._NotificationToast.LauncherUpdated_NotifSubtitle,
932-
VerString + (IsPreview ? "-preview" : ""),
933-
Lang._SettingsPage.PageTitle,
934-
Lang._SettingsPage.Update_SeeChangelog)
935-
)
936-
.AddAppHeroImagePath(heroImage);
928+
.SetTitle(Lang._NotificationToast
929+
.LauncherUpdated_NotifTitle)
930+
.SetContent(
931+
string
932+
.Format(Lang._NotificationToast.LauncherUpdated_NotifSubtitle,
933+
VerString + (IsPreview
934+
? "-preview"
935+
: ""),
936+
Lang._SettingsPage
937+
.PageTitle,
938+
Lang._SettingsPage
939+
.Update_SeeChangelog)
940+
)
941+
.AddAppHeroImagePath(heroImage);
937942

938943
// Get notification service
939944
Windows.UI.Notifications.ToastNotification notificationService =
940-
WindowUtility.CurrentToastNotificationService?.CreateToastNotification(toastContent);
945+
WindowUtility.CurrentToastNotificationService.CreateToastNotification(toastContent);
941946

942947
// Spawn notification service
943948
Windows.UI.Notifications.ToastNotifier notifier =
944-
WindowUtility.CurrentToastNotificationService?.CreateToastNotifier();
949+
WindowUtility.CurrentToastNotificationService.CreateToastNotifier();
945950
notifier.Show(notificationService);
946951
}
947-
catch { }
952+
catch (Exception ex)
953+
{
954+
LogWriteLine($"[SpawnAppUpdatedNotification] Failed to spawn toast notification!\r\n{ex}",
955+
LogType.Error, true);
956+
SentryHelper.ExceptionHandler(ex);
957+
}
948958
}
949959
}
950960
catch
@@ -1950,7 +1960,7 @@ private void RestoreCurrentRegion()
19501960
List<string>? gameNameCollection = LauncherMetadataHelper.GetGameNameCollection();
19511961
_ = LauncherMetadataHelper.GetGameRegionCollection(gameName);
19521962

1953-
var indexCategory = gameNameCollection?.IndexOf(gameName!) ?? -1;
1963+
var indexCategory = gameNameCollection?.IndexOf(gameName) ?? -1;
19541964
if (indexCategory < 0) indexCategory = 0;
19551965

19561966
var indexRegion = LauncherMetadataHelper.GetPreviousGameRegion(gameName);

0 commit comments

Comments
 (0)