Add support for priority

Set default title to topic unique, as displayed in subscriptions list, if not provided
Increase toast timeout to 5 seconds
This commit is contained in:
Alexander Horner
2022-12-08 19:54:14 +00:00
parent d90ddc3be4
commit 7f73bd2cd1
5 changed files with 37 additions and 7 deletions

View File

@@ -54,7 +54,19 @@ namespace ntfysh_client
private void OnNotificationReceive(object sender, NotificationReceiveEventArgs e)
{
notifyIcon.ShowBalloonTip(3000, e.Title, e.Message, ToolTipIcon.Info);
ToolTipIcon priorityIcon = e.Priority switch
{
NotificationPriority.Max => ToolTipIcon.Error,
NotificationPriority.High => ToolTipIcon.Warning,
NotificationPriority.Default => ToolTipIcon.Info,
NotificationPriority.Low => ToolTipIcon.Info,
NotificationPriority.Min => ToolTipIcon.None,
_ => throw new ArgumentOutOfRangeException("Unknown priority received")
};
string finalTitle = string.IsNullOrWhiteSpace(e.Title) ? $"{e.Sender.TopicId}@{e.Sender.ServerUrl}" : e.Title;
notifyIcon.ShowBalloonTip(5000, finalTitle, e.Message, priorityIcon);
}
private void OnConnectionMultiAttemptFailure(NotificationListener sender, SubscribedTopic topic)