Skip to content

Commit 849f102

Browse files
committed
fix: Do not crash if there are no notifications
1 parent f9e463b commit 849f102

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Source/Menu/Notifications/NotificationManager.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// COPYRIGHT 2009 - 2024 by the Open Rails project.
1+
// COPYRIGHT 2009 - 2024 by the Open Rails project.
22
//
33
// This file is part of Open Rails.
44
//
@@ -224,6 +224,10 @@ public void PopulatePage()
224224
{
225225
PopulateRetryPage();
226226
}
227+
else if (Notifications.NotificationList.Count == 0)
228+
{
229+
PopulateEmptyPage();
230+
}
227231
else
228232
{
229233
Settings.LastViewNotificationDate = $"{DateTime.Today:yyyy-MM-dd}";
@@ -268,6 +272,15 @@ private void PopulateRetryPage()
268272
Page.NDetailList.Add(new NRetryControl(Page, "Retry", 140, "Try again to fetch notifications", MainForm));
269273
}
270274

275+
private void PopulateEmptyPage()
276+
{
277+
NewPages.Count = 0;
278+
279+
// Reports no notifications.
280+
var today = DateTime.Now.Date;
281+
Page.NDetailList.Add(new NTitleControl(Panel, 1, 1, $"{today:dd-MMM-yy}", "No notifications"));
282+
}
283+
271284
#region Process Criteria
272285
private bool AreNotificationChecksMet(Notification notification)
273286
{

0 commit comments

Comments
 (0)