diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c512c8..36ac57f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,16 @@ # GameVault App Changelog +## 1.17.3 +Recommended Gamevault Server Version: `v16.1.1` +### Changes +- Bug fix: Installed games were sometimes not displayed if they were deleted from the server. +- Bug fix: Completed downloads were sometimes displayed as paused after a restart. +- Bug fix: YouTube videos are loading again + ## 1.17.2 Recommended Gamevault Server Version: `v15.0.2` ### Changes -- Added authorization to the admin panel’s registration action, allowing administrators to register users even when server-side registration is disabled. +- Added authorization to the admin panels registration action, allowing administrators to register users even when server-side registration is disabled. - Extended the existing installation overwrite warning to allow users to continue the installation at their own risk. - Performance optimization in the community tab - Bug fix: OAuth access token expiration was not calculated correctly under certain circumstances. diff --git a/gamevault/AssemblyInfo.cs b/gamevault/AssemblyInfo.cs index bfb06b5..1e91ab7 100644 --- a/gamevault/AssemblyInfo.cs +++ b/gamevault/AssemblyInfo.cs @@ -11,7 +11,7 @@ //(used if a resource is not found in the page, // app, or any theme specific resource dictionaries) )] -[assembly: AssemblyVersion("1.17.2.0")] +[assembly: AssemblyVersion("1.17.3.0")] [assembly: AssemblyCopyright("© Phalcode™. All Rights Reserved.")] #if DEBUG [assembly: XmlnsDefinition("debug-mode", "Namespace")] diff --git a/gamevault/Helper/Web/HttpClientDownloadWithProgress.cs b/gamevault/Helper/Web/HttpClientDownloadWithProgress.cs index 7a6ae8c..35fd316 100644 --- a/gamevault/Helper/Web/HttpClientDownloadWithProgress.cs +++ b/gamevault/Helper/Web/HttpClientDownloadWithProgress.cs @@ -190,7 +190,7 @@ private void TriggerProgressChanged(long totalDownloadSize, long currentBytesRea return; totalDownloadSize = PreResumeSize == -1 ? totalDownloadSize : PreResumeSize; - double progressPercentage = Math.Round((double)totalBytesRead / totalDownloadSize * 100, 0); + double progressPercentage = (double)totalBytesRead / totalDownloadSize * 100; ProgressChanged(totalDownloadSize, currentBytesRead, totalBytesRead, progressPercentage, ResumePosition); } public void Cancel() diff --git a/gamevault/UserControls/InstallUserControl.xaml.cs b/gamevault/UserControls/InstallUserControl.xaml.cs index a99a7b6..d7c7eb1 100644 --- a/gamevault/UserControls/InstallUserControl.xaml.cs +++ b/gamevault/UserControls/InstallUserControl.xaml.cs @@ -40,6 +40,33 @@ private async void UserControl_Loaded(object sender, RoutedEventArgs e) InstallViewModel.Instance.InstalledGamesFilter = CollectionViewSource.GetDefaultView(InstallViewModel.Instance.InstalledGames); } } + private List GetGamesFromOfflineCache(Dictionary games) + { + List offlineCacheGames = new List(); + foreach (KeyValuePair entry in games) + { + string objectFromFile = Preferences.Get(entry.Key.ToString(), LoginManager.Instance.GetUserProfile().OfflineCache); + if (objectFromFile != string.Empty) + { + try + { + string decompressedObject = StringCompressor.DecompressString(objectFromFile); + Game? deserializedObject = JsonSerializer.Deserialize(decompressedObject); + if (deserializedObject != null) + { + offlineCacheGames.Add(deserializedObject); + } + } + catch (FormatException exFormat) { } + } + else + { + string gameTitle = Path.GetFileName(entry.Value); + offlineCacheGames.Add(new Game() { ID = entry.Key, Title = gameTitle.Substring(gameTitle.IndexOf(')') + 1) }); + } + } + return offlineCacheGames; + } public async Task RestoreInstalledGames(bool fromCLI = false) { if (gamesRestored) @@ -98,33 +125,26 @@ public async Task RestoreInstalledGames(bool fromCLI = false) if (LoginManager.Instance.IsLoggedIn()) { string gameList = await WebHelper.GetAsync(@$"{SettingsViewModel.Instance.ServerUrl}/api/games?filter.id=$in:{gameIds}&limit=-1"); - return JsonSerializer.Deserialize>(gameList).Data; - } - else - { - List offlineCacheGames = new List(); - foreach (KeyValuePair entry in foundGames) + Game[] serverGames = JsonSerializer.Deserialize>(gameList)!.Data; + + var serverGameIds = new HashSet(serverGames.Select(g => g.ID)); + var missingGames = foundGames.Where(kvp => !serverGameIds.Contains(kvp.Key)) + .ToDictionary(kvp => kvp.Key, kvp => kvp.Value); + + //Make sure to display installed games that are already deleted on the server + if (missingGames.Count > 0) { - string objectFromFile = Preferences.Get(entry.Key.ToString(), LoginManager.Instance.GetUserProfile().OfflineCache); - if (objectFromFile != string.Empty) - { - try - { - string decompressedObject = StringCompressor.DecompressString(objectFromFile); - Game? deserializedObject = JsonSerializer.Deserialize(decompressedObject); - if (deserializedObject != null) - { - offlineCacheGames.Add(deserializedObject); - } - } - catch (FormatException exFormat) { } - } - else + List offlineCacheGames = GetGamesFromOfflineCache(foundGames); + if (offlineCacheGames.Count > 0) { - string gameTitle = Path.GetFileName(entry.Value); - offlineCacheGames.Add(new Game() { ID = entry.Key, Title = gameTitle.Substring(gameTitle.IndexOf(')') + 1) }); + serverGames = serverGames.Concat(offlineCacheGames).ToArray(); } } + return serverGames; + } + else + { + List offlineCacheGames = GetGamesFromOfflineCache(foundGames); return offlineCacheGames.ToArray(); } } diff --git a/gamevault/gamevault.csproj b/gamevault/gamevault.csproj index 34af929..80f9c01 100644 --- a/gamevault/gamevault.csproj +++ b/gamevault/gamevault.csproj @@ -57,7 +57,7 @@ - + @@ -67,7 +67,7 @@ - +