From 2805263a633fc3da8b8bd59ad6f3ac57bcbb3264 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 4 Sep 2024 17:47:58 +0100 Subject: [PATCH] Fix remaining activity tracker related bugs --- Bloxstrap/Integrations/ActivityWatcher.cs | 13 +++++++++++-- .../ContextMenu/ServerHistoryViewModel.cs | 3 +-- .../UI/ViewModels/Installer/WelcomeViewModel.cs | 1 - 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Bloxstrap/Integrations/ActivityWatcher.cs b/Bloxstrap/Integrations/ActivityWatcher.cs index 914493be..c7723976 100644 --- a/Bloxstrap/Integrations/ActivityWatcher.cs +++ b/Bloxstrap/Integrations/ActivityWatcher.cs @@ -125,7 +125,6 @@ public async void Start() } } - // TODO: i need to double check how this handles failed game joins (connection error, invalid permissions, etc) private void ReadLogEntry(string entry) { const string LOG_IDENT = "ActivityWatcher::ReadLogEntry"; @@ -142,7 +141,17 @@ private void ReadLogEntry(string entry) App.Logger.WriteLine(LOG_IDENT, $"Read {_logEntriesRead} log entries"); if (entry.Contains(GameLeavingEntry)) - OnAppClose?.Invoke(this, new EventArgs()); + { + App.Logger.WriteLine(LOG_IDENT, "User is back into the desktop app"); + + OnAppClose?.Invoke(this, EventArgs.Empty); + + if (Data.PlaceId != 0 && !InGame) + { + App.Logger.WriteLine(LOG_IDENT, "User appears to be leaving from a cancelled/errored join"); + Data = new(); + } + } if (!InGame && Data.PlaceId == 0) { diff --git a/Bloxstrap/UI/ViewModels/ContextMenu/ServerHistoryViewModel.cs b/Bloxstrap/UI/ViewModels/ContextMenu/ServerHistoryViewModel.cs index bea9d615..f48e534a 100644 --- a/Bloxstrap/UI/ViewModels/ContextMenu/ServerHistoryViewModel.cs +++ b/Bloxstrap/UI/ViewModels/ContextMenu/ServerHistoryViewModel.cs @@ -36,8 +36,7 @@ private async void LoadData() if (entries.Any()) { - // TODO: this will duplicate universe ids - string universeIds = String.Join(',', entries.Select(x => x.UniverseId)); + string universeIds = String.Join(',', entries.GroupBy(x => x.UniverseId).Select(x => x.First())); try { diff --git a/Bloxstrap/UI/ViewModels/Installer/WelcomeViewModel.cs b/Bloxstrap/UI/ViewModels/Installer/WelcomeViewModel.cs index 41190d87..025b84a3 100644 --- a/Bloxstrap/UI/ViewModels/Installer/WelcomeViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Installer/WelcomeViewModel.cs @@ -1,6 +1,5 @@ namespace Bloxstrap.UI.ViewModels.Installer { - // TODO: administrator check? public class WelcomeViewModel : NotifyPropertyChangedViewModel { // formatting is done here instead of in xaml, it's just a bit easier