Archived
1
0

Notification system development 1

This commit is contained in:
Michael Gordeev
2018-08-18 09:21:57 +03:00
parent 26907c9aac
commit 4c4f4ed967
13 changed files with 291 additions and 155 deletions
+29 -11
View File
@@ -15,7 +15,7 @@ namespace FoxTube.Background
{
public enum NotificationType
{
Video, Comment, Post, Internal
Video, Comment, Post, Internal, Changelog
}
public sealed class Notification
@@ -35,6 +35,7 @@ namespace FoxTube.Background
Channel = channelName;
Content = content;
TimeStamp = date;
Id = id;
Type = TypeConversion(type);
Avatar = avatarUrl == null? "ms-appx:///Assets/Icons/Profile.png" : avatarUrl;
Thumbnail = thumbnailUrl;
@@ -136,13 +137,13 @@ namespace FoxTube.Background
return item;
}
public ToastNotification GetToast(int assignedId)
public ToastNotification GetToast()
{
XmlDocument template = new XmlDocument();
switch (Type)
{
case NotificationType.Comment:
template.LoadXml($@"<toast launch='type=comment&amp;action=open&amp;id={assignedId}'>
template.LoadXml($@"<toast launch='comment&{Id}'>
<visual>
<binding template='ToastGeneric'>
<image placement='appLogoOverride' hint-crop='circle' src='{Avatar}'/>
@@ -156,16 +157,16 @@ namespace FoxTube.Background
<action content='Send' imageUri='Assets/Icons/Send.png'
hint-inputId='textBox' activationType='background'
arguments='type=comment&amp;action=sendReply&amp;id={assignedId}'/>
arguments='comment&{Id}&send'/>
<action content='Like'
arguments='type=comment&amp;action=like&amp;id={assignedId}'/>
arguments='comment&{Id}&like'/>
</actions>
</toast>");
break;
case NotificationType.Video:
template.LoadXml($@"<toast launch='action=viewPhoto&amp;photoId=92187'>
template.LoadXml($@"<toast launch='video&{Id}'>
<visual>
<binding template='ToastGeneric'>
<image placement='appLogoOverride' hint-crop='circle' src='{Avatar}'/>
@@ -178,16 +179,29 @@ namespace FoxTube.Background
<actions>
<action content='Watch later'
activationType='background'
arguments='likePhoto&amp;photoId=92187'/>
arguments='video&{Id}&later'/>
<action content='Go to channel'
arguments='action=commentPhoto&amp;photoId=92187'/>
arguments='video&{Id}&channel'/>
</actions>
</toast>");
break;
case NotificationType.Changelog:
template.LoadXml($@"<toast launch='changelog&{Id}'>
<visual>
<binding template='ToastGeneric'>
<image placement='hero' src='Assets/WhatsNewThumb.png'/>
<image placement='appLogoOverride' hint-crop='circle' src='Assets/LogoAvatar.png'/>
<text>{Content}</text>
<text>Changelog</text>
</binding>
</visual>
</toast>");
break;
case NotificationType.Internal:
string thumb1 = string.IsNullOrWhiteSpace(Thumbnail) ? "Assets/AnnouncementThumb.png" : Thumbnail;
template.LoadXml($@"<toast launch='action=openThread&amp;threadId=92187'>
template.LoadXml($@"<toast launch='internal&{Id}'>
<visual>
<binding template='ToastGeneric'>
<image placement='hero' src='{thumb1}'/>
@@ -199,9 +213,9 @@ namespace FoxTube.Background
<actions>
<action content='Watch full post'
arguments='action=commentPhoto&amp;photoId=92187'/>
arguments='internal&{Id}'/>
<action content='Manage notifications'
arguments='action=commentPhoto&amp;photoId=92187'/>
arguments='notifications'/>
</actions>
</toast>");
break;
@@ -246,6 +260,8 @@ namespace FoxTube.Background
return "post";
case NotificationType.Video:
return "video";
case NotificationType.Changelog:
return "changelog";
default:
return "internal";
}
@@ -261,6 +277,8 @@ namespace FoxTube.Background
return NotificationType.Post;
case "video":
return NotificationType.Video;
case "changelog":
return NotificationType.Changelog;
default:
return NotificationType.Internal;
}