Skip to content

Commit 20514b0

Browse files
committed
Handles minimal notification
1 parent 2728d6d commit 20514b0

File tree

2 files changed

+65
-61
lines changed

2 files changed

+65
-61
lines changed

Source/Menu/Notifications/NotificationManager.cs

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -182,29 +182,30 @@ void SetUpdateNotificationPage()
182182
new NTitleControl(page, Index + 1, list.Count, n.Date, n.Title).Add();
183183

184184
// Check constraints for the MetList.
185-
var failingCheck = (n.Met.ItemList?.Count > 0 && n.Met.CheckIdList?.Count > 0)
186-
? CheckConstraints(n)
187-
: null;
185+
//var failingCheck = (n.Met.ItemList?.Count > 0 && n.Met.CheckIdList?.Count > 0)
186+
// ? CheckConstraints(n)
187+
// : null;
188188

189189
// If any check fails then its UnmetList is added to the page, otherwise the MetList is added.
190-
n.PrefixItemList?.ForEach(item => AddItemToPage(page, item));
191-
if (failingCheck == null)
192-
{
193-
n.Met.ItemList?.ForEach(item => AddItemToPage(page, item));
194-
}
195-
else
196-
{
197-
if (failingCheck.UnmetItemList == null) // Omit this section to skip the notification entirely.
198-
{
199-
// Don't skip if there is only one notification.
200-
if (list.Count > 1) skipPage = true;
201-
}
202-
else
203-
{
204-
failingCheck.UnmetItemList?.ForEach(item => AddItemToPage(page, item));
205-
}
206-
}
207-
n.SuffixItemList?.ForEach(item => AddItemToPage(page, item));
190+
//n.PrefixItemList?.ForEach(item => AddItemToPage(page, item));
191+
//if (failingCheck == null)
192+
//{
193+
// n.Met.ItemList?.ForEach(item => AddItemToPage(page, item));
194+
//}
195+
//else
196+
//{
197+
// if (failingCheck.UnmetItemList == null) // Omit this section to skip the notification entirely.
198+
// {
199+
// // Don't skip if there is only one notification.
200+
// if (list.Count > 1) skipPage = true;
201+
// }
202+
// else
203+
// {
204+
// failingCheck.UnmetItemList?.ForEach(item => AddItemToPage(page, item));
205+
// }
206+
//}
207+
//n.SuffixItemList?.ForEach(item => AddItemToPage(page, item));
208+
n.ItemList?.ForEach(item => AddItemToPage(page, item));
208209
if (skipPage == false) PageList.Add(page);
209210
}
210211

@@ -218,24 +219,24 @@ void SetUpdateNotificationPage()
218219
private Check CheckConstraints(Notification n)
219220
{
220221
Check failingCheck = null;
221-
foreach (var nc in n.Met.CheckIdList) // CheckIdList is optional
222+
foreach (var checkName in n.CheckIdList) // CheckIdList is optional
222223
{
223-
LogChecks(nc);
224+
LogChecks(checkName);
224225

225226
// Find the matching check
226-
var check = Notifications.CheckList.Where(c => c.Id == nc.Id).FirstOrDefault();
227+
var check = Notifications.CheckList.Where(c => c.Id == checkName).FirstOrDefault();
227228
if (check != null && check.AnyOfList.Count() > 0)
228229
{
229230
foreach(var anyOf in check.AnyOfList)
230231
{
231-
if (anyOf is Excludes)
232-
{
233-
if (CheckAllMatch(anyOf.AllOfList) == true) return check; // immediate fail so quit
234-
}
235-
if (anyOf is Includes)
236-
{
237-
if (CheckAllMatch(anyOf.AllOfList) == false) failingCheck = check; // fail but continue testing other Includes
238-
}
232+
//if (anyOf is Excludes)
233+
//{
234+
// if (CheckAllMatch(anyOf.AllOfList) == true) return check; // immediate fail so quit
235+
//}
236+
//if (anyOf is Includes)
237+
//{
238+
// if (CheckAllMatch(anyOf.AllOfList) == false) failingCheck = check; // fail but continue testing other Includes
239+
//}
239240
}
240241
}
241242
}
@@ -323,9 +324,9 @@ public void DropUnusedUpdateNotifications()
323324
continue;
324325

325326
// Mark unused updates for deletion outside loop
326-
n.ToDelete = lowerUpdateMode != updateModeSetting;
327+
//n.ToDelete = lowerUpdateMode != updateModeSetting;
327328
}
328-
Notifications.NotificationList.RemoveAll(n => n.ToDelete);
329+
//Notifications.NotificationList.RemoveAll(n => n.ToDelete);
329330
}
330331

331332
public void ReplaceParameters()
@@ -334,9 +335,10 @@ public void ReplaceParameters()
334335
{
335336
n.Title = ReplaceParameter(n.Title);
336337
n.Date = ReplaceParameter(n.Date);
337-
n.PrefixItemList?.ForEach(item => ReplaceItemParameter(item));
338-
n.Met.ItemList?.ForEach(item => ReplaceItemParameter(item));
339-
n.SuffixItemList?.ForEach(item => ReplaceItemParameter(item));
338+
//n.PrefixItemList?.ForEach(item => ReplaceItemParameter(item));
339+
//n.Met.ItemList?.ForEach(item => ReplaceItemParameter(item));
340+
//n.SuffixItemList?.ForEach(item => ReplaceItemParameter(item));
341+
n.ItemList?.ForEach(item => ReplaceItemParameter(item));
340342
}
341343
foreach (var list in Notifications.CheckList)
342344
{
@@ -557,9 +559,9 @@ public void LogNotification(Notification n)
557559
{
558560
AppendToLog($"Notification: {n.Title}");
559561
}
560-
public void LogChecks(CheckId ci)
562+
public void LogChecks(string checkName)
561563
{
562-
AppendToLog($"CheckId: {ci.Id}");
564+
AppendToLog($"CheckId: {checkName}");
563565
}
564566
public void LogCheckContains(string value, bool sense, string content, bool result)
565567
{

Source/Menu/Notifications/Notifications.cs

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ public class Notification
3737
public string Date { get; set; }
3838
public string Title { get; set; }
3939
public string UpdateMode { get; set; }
40-
public List<Item> PrefixItemList { get; set; }
41-
public Met Met { get; set; }
42-
public List<Item> SuffixItemList { get; set; }
43-
public bool ToDelete { get; set; } = false; // So we can mark items for deletion and then delete in single statement.
40+
public List<Item> ItemList { get; set; }
41+
public List<string> CheckIdList { get; set; }
4442
}
4543
class Record : Item
4644
{
@@ -69,35 +67,39 @@ public class Item
6967
public string Color { get; set; } = "black";
7068
public int Indent { get; set; } = 140;
7169
}
72-
public class Met
73-
{
74-
public List<Item> ItemList { get; set; }
75-
public List<CheckId> CheckIdList { get; set; }
76-
}
77-
public class CheckId
78-
{
79-
public string Id { get; set; }
80-
}
70+
//public class Met
71+
//{
72+
// public List<Item> ItemList { get; set; }
73+
// public List<CheckId> CheckIdList { get; set; }
74+
//}
75+
//public class CheckId
76+
//{
77+
// public string Id { get; set; }
78+
//}
8179

8280
public class Check
8381
{
8482
public string Id { get; set; }
85-
public List<CheckAllOf> AnyOfList { get; set; }
86-
public List<Item> UnmetItemList { get; set; }
83+
public List<AllOf> AnyOfList { get; set; }
84+
//public List<Item> UnmetItemList { get; set; }
8785
}
8886

89-
public class CheckAllOf
87+
//public class CheckAllOf
88+
//{
89+
// public List<Criteria> AllOfList { get; set; }
90+
//}
91+
public class AllOf
9092
{
9193
public List<Criteria> AllOfList { get; set; }
9294
}
9395

94-
public class Excludes : CheckAllOf
95-
{
96-
}
96+
//public class Excludes : CheckAllOf
97+
//{
98+
//}
9799

98-
public class Includes : CheckAllOf
99-
{
100-
}
100+
//public class Includes : CheckAllOf
101+
//{
102+
//}
101103

102104
class Contains : Criteria { }
103105
class NotContains : Criteria { }

0 commit comments

Comments
 (0)