From 8051e3710b6717ab428811cd0d3bbecf5a4ca2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Arrouye?= <5017270+tarrouye@users.noreply.github.com> Date: Sun, 4 Jun 2023 21:32:20 -0700 Subject: [PATCH] Only refresh metadata, not whole applications list --- .../UI/ViewModels/MainWindowViewModel.cs | 18 +++++++++++++++++- .../App/ApplicationLibrary.cs | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs index 5486bd67d..f920023cd 100644 --- a/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs @@ -1363,7 +1363,7 @@ namespace Ryujinx.Ava.UI.ViewModels if (prevUserId != AccountManager.LastOpenedUser.UserId) { // current user changed, so refresh application metadata - LoadApplications(); + RefreshApplicationsMetadata(); } } @@ -1372,6 +1372,22 @@ namespace Ryujinx.Ava.UI.ViewModels AppHost.Device.System.SimulateWakeUpMessage(); } + private async void RefreshApplicationsMetadata() + { + await Task.Run(() => { + foreach (var app in _applications) + { + var metadata = ApplicationLibrary.LoadAndSaveMetaData(AccountManager.LastOpenedUser.UserId.ToLibHacFsUid(), app.TitleId); + app.Favorite = metadata.Favorite; + app.LastPlayed = metadata.LastPlayed; + app.TimePlayedNum = metadata.TimePlayed; + app.TimePlayed = ApplicationLibrary.ConvertSecondsToFormattedString(metadata.TimePlayed); + } + }); + + RefreshView(); + } + public async void LoadApplications() { await Dispatcher.UIThread.InvokeAsync(() => diff --git a/src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs b/src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs index 2f473eac5..4875cafbf 100644 --- a/src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs +++ b/src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs @@ -733,7 +733,7 @@ namespace Ryujinx.Ui.App.Common return applicationIcon ?? _ncaIcon; } - private static string ConvertSecondsToFormattedString(double seconds) + public static string ConvertSecondsToFormattedString(double seconds) { System.TimeSpan time = System.TimeSpan.FromSeconds(seconds);