diff --git a/GlobalAssemblyInfo.cs b/GlobalAssemblyInfo.cs index 7694d93..d5df341 100644 --- a/GlobalAssemblyInfo.cs +++ b/GlobalAssemblyInfo.cs @@ -22,5 +22,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.8.2.0")] -[assembly: AssemblyFileVersion("1.8.2.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.8.3.0")] +[assembly: AssemblyFileVersion("1.8.3.0")] \ No newline at end of file diff --git a/Livestream.Monitor/Core/Utility/WindowSettingsBuilder.cs b/Livestream.Monitor/Core/Utility/WindowSettingsBuilder.cs index f7d9bba..3a390e6 100644 --- a/Livestream.Monitor/Core/Utility/WindowSettingsBuilder.cs +++ b/Livestream.Monitor/Core/Utility/WindowSettingsBuilder.cs @@ -38,6 +38,7 @@ public WindowSettingsBuilder NoResizeBorderless() { WithResizeMode(ResizeMode.NoResize); WithWindowStyle(WindowStyle.None); + settings.BorderThickness = new Thickness(0); return this; } diff --git a/Livestream.Monitor/Model/Monitoring/MonitorStreamsModel.cs b/Livestream.Monitor/Model/Monitoring/MonitorStreamsModel.cs index 4ab1f0c..bc50689 100644 --- a/Livestream.Monitor/Model/Monitoring/MonitorStreamsModel.cs +++ b/Livestream.Monitor/Model/Monitoring/MonitorStreamsModel.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Linq; @@ -18,6 +19,7 @@ public class MonitorStreamsModel : PropertyChangedBase, IMonitorStreamsModel private bool initialised; private bool canRefreshLivestreams = true; + private bool queryOfflineStreams = true; private LivestreamModel selectedLivestream; #region Design Time Constructor @@ -146,19 +148,12 @@ public async Task RefreshLivestreams() var offlineStreams = Livestreams.Where(x => !onlineStreams.Any(y => y.Channel.Name.IsEqualTo(x.Id))).ToList(); offlineStreams.ForEach(x => x.Offline()); // mark all remaining streams as offline immediately - var offlineTasks = offlineStreams.Select(x => new + if (queryOfflineStreams) { - Livestream = x, - OfflineData = twitchTvClient.GetChannelDetails(x.Id) - }).ToList(); - - await Task.WhenAll(offlineTasks.Select(x => x.OfflineData)); - foreach (var offlineTask in offlineTasks) - { - var offlineData = offlineTask.OfflineData.Result; - if (offlineData == null) continue; - - offlineTask.Livestream.PopulateWithChannel(offlineData); + await QueryOfflineStreams(offlineStreams); + // We only need to query offline streams one time to get the channel info + // It's a waste of resources to query for updates to offline streams + queryOfflineStreams = false; } } catch (Exception) @@ -182,6 +177,24 @@ protected virtual void OnOnlineLivestreamsRefreshComplete() OnlineLivestreamsRefreshComplete?.Invoke(this, EventArgs.Empty); } + private async Task QueryOfflineStreams(List offlineStreams) + { + var offlineTasks = offlineStreams.Select(x => new + { + Livestream = x, + OfflineData = twitchTvClient.GetChannelDetails(x.Id) + }).ToList(); + + await Task.WhenAll(offlineTasks.Select(x => x.OfflineData)); + foreach (var offlineTask in offlineTasks) + { + var offlineData = offlineTask.OfflineData.Result; + if (offlineData == null) continue; + + offlineTask.Livestream.PopulateWithChannel(offlineData); + } + } + private void LoadLivestreams() { if (initialised) return; diff --git a/Livestream.Monitor/Model/NotificationHandler.cs b/Livestream.Monitor/Model/NotificationHandler.cs index 96fa8dd..24f5ea1 100644 --- a/Livestream.Monitor/Model/NotificationHandler.cs +++ b/Livestream.Monitor/Model/NotificationHandler.cs @@ -69,8 +69,7 @@ public void AddNotification(LivestreamNotification livestreamNotification) private void ShowNotification(LivestreamNotification livestreamNotification) { var vmTopLeft = GetNotificationTopLeft(livestreamNotification); - var settings = new WindowSettingsBuilder().WithWindowStyle(WindowStyle.None) - .WithResizeMode(ResizeMode.NoResize) + var settings = new WindowSettingsBuilder().NoResizeBorderless() .WithTopLeft(vmTopLeft.Y, vmTopLeft.X) .TransparentBackground() .AsTopmost() diff --git a/Livestream.Monitor/Model/StreamLauncher.cs b/Livestream.Monitor/Model/StreamLauncher.cs index 90521e9..82e4dbf 100644 --- a/Livestream.Monitor/Model/StreamLauncher.cs +++ b/Livestream.Monitor/Model/StreamLauncher.cs @@ -8,7 +8,6 @@ using Livestream.Monitor.Core.Utility; using Livestream.Monitor.Model.Monitoring; using Livestream.Monitor.ViewModels; -using Livestream.Monitor.Views; namespace Livestream.Monitor.Model { @@ -184,10 +183,9 @@ private MessageBoxViewModel ShowLivestreamerLoadMessageBox(string title, string DisplayName = title, MessageText = messageText }; - + var settings = new WindowSettingsBuilder().SizeToContent() - .WithWindowStyle(WindowStyle.ToolWindow) - .WithResizeMode(ResizeMode.NoResize) + .NoResizeBorderless() .Create(); windowManager.ShowWindow(messageBoxViewModel, null, settings); @@ -206,8 +204,7 @@ private bool CheckLivestreamerExists() }; var settings = new WindowSettingsBuilder().SizeToContent() - .WithWindowStyle(WindowStyle.ToolWindow) - .WithResizeMode(ResizeMode.NoResize) + .NoResizeBorderless() .Create(); windowManager.ShowWindow(msgBox, null, settings);