-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInboxSummaryService.cs
More file actions
41 lines (38 loc) · 1.33 KB
/
InboxSummaryService.cs
File metadata and controls
41 lines (38 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
namespace BlippoAccess
{
/// <summary>
/// Builds inbox summary announcements from viewer message state.
/// </summary>
internal static class InboxSummaryService
{
/// <summary>
/// Attempts to build a messages summary announcement.
/// </summary>
/// <param name="announcement">Summary announcement when available.</param>
/// <returns>True when viewer data is available; otherwise false.</returns>
public static bool TryBuildAnnouncement(out string announcement)
{
announcement = string.Empty;
if (ViewerData_v1.current == null || ViewerData_v1.current.messagesInInbox == null)
{
return false;
}
var total = ViewerData_v1.current.messagesInInbox.Count;
if (total <= 0)
{
announcement = Loc.Get("messages_summary_empty");
return true;
}
var unread = 0;
foreach (var messageStatus in ViewerData_v1.current.messagesInInbox.Values)
{
if (messageStatus != null && !messageStatus.read)
{
unread++;
}
}
announcement = Loc.Get("messages_summary_counts", total, unread);
return true;
}
}
}