Started work on #1

This commit is contained in:
Martin Barker
2023-02-03 18:59:07 +00:00
parent 0af2d24b4c
commit 03b620ecec
4 changed files with 72 additions and 1 deletions

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TwitchDesktopNotifications.JsonStructure.Helix;
namespace TwitchDesktopNotifications.Core
{
internal class NotifyManager
{
public Boolean shouldNotify(String streamerName)
{
return notifyAll || !DataStore.GetInstance().Store.SteamersToNotify.Streamers.Contains(streamerName);
}
public void AddStreamerToNotifyList(String streamerName)
{
DataStore.GetInstance().Store.SteamersToNotify.Streamers.Add(streamerName);
DataStore.GetInstance().Save();
}
public void RemoveStreamerToNotifyList(String streamerName)
{
DataStore.GetInstance().Store.SteamersToNotify.Streamers.Remove(streamerName);
DataStore.GetInstance().Save();
}
public void ClearListOfEnabled()
{
DataStore.GetInstance().Store.SteamersToNotify.Streamers = new List<string>();
DataStore.GetInstance().Save();
}
public bool notifyAll
{
get
{
return DataStore.GetInstance().Store.SteamersToNotify.notifyAll;
}
set {
DataStore.GetInstance().Store.SteamersToNotify.notifyAll = value;
DataStore.GetInstance().Save();
}
}
}
}

View File

@@ -125,9 +125,16 @@ namespace TwitchDesktopNotifications.Core
currentlyLive = following.Data;
}catch(System.Exception ex)
{
if (!ex.Message.Contains("Notification"))
{
MessageBox.Show("Twitch Connection not authenticated you need to Reconnect it.", "Twitch Notify");
}
else
{
MessageBox.Show("Unable to use Windows Notifications.", "Twitch Notify");
}
}
}
public void Refresh()

View File

@@ -0,0 +1,13 @@
using System.Text.Json.Serialization;
namespace TwitchDesktopNotifications.JsonStructure
{
internal class SteamersToNotify
{
[JsonPropertyName("notifyAll")]
public Boolean notifyAll = true;
[JsonPropertyName("notify")]
public List<String> Streamers { get; set; } = new List<String>();
}
}

View File

@@ -17,5 +17,8 @@ namespace TwitchDesktopNotifications.JsonStructure
[JsonPropertyName("user_data")]
public UserData UserData { get; set; }
[JsonPropertyName("notifications_for")]
public SteamersToNotify SteamersToNotify { get; set; };
}
}