Apply suggestions from code review

Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
Théo Arrouye 2023-06-15 09:11:40 -07:00 committed by GitHub
parent a0128ce8af
commit dd96f2df10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View file

@ -1357,12 +1357,12 @@ namespace Ryujinx.Ava.UI.ViewModels
public async void ManageProfiles() public async void ManageProfiles()
{ {
var prevUserId = AccountManager.LastOpenedUser.UserId; var oldLastOpenedUserId = AccountManager.LastOpenedUser.UserId;
await NavigationDialogHost.Show(AccountManager, ContentManager, VirtualFileSystem, LibHacHorizonManager.RyujinxClient); await NavigationDialogHost.Show(AccountManager, ContentManager, VirtualFileSystem, LibHacHorizonManager.RyujinxClient);
if (prevUserId != AccountManager.LastOpenedUser.UserId) if (oldLastOpenedUserId != AccountManager.LastOpenedUser.UserId)
{ {
// current user changed, so refresh application metadata // Opened user changed, so refresh application metadata.
_ = Task.Run(RefreshApplicationsMetadata); _ = Task.Run(RefreshApplicationsMetadata);
} }
} }
@ -1377,6 +1377,7 @@ namespace Ryujinx.Ava.UI.ViewModels
foreach (var app in _applications) foreach (var app in _applications)
{ {
var metadata = ApplicationLibrary.LoadAndSaveMetaData(AccountManager.LastOpenedUser.UserId.ToLibHacFsUid(), app.TitleId); var metadata = ApplicationLibrary.LoadAndSaveMetaData(AccountManager.LastOpenedUser.UserId.ToLibHacFsUid(), app.TitleId);
app.Favorite = metadata.Favorite; app.Favorite = metadata.Favorite;
app.LastPlayed = metadata.LastPlayed; app.LastPlayed = metadata.LastPlayed;
app.TimePlayedNum = metadata.TimePlayed; app.TimePlayedNum = metadata.TimePlayed;

View file

@ -516,14 +516,14 @@ namespace Ryujinx.Ui.App.Common
Directory.CreateDirectory(metadataFolder); Directory.CreateDirectory(metadataFolder);
// Handle migration from old default to current user // NOTE: Handle migration from old default to current user. Should be removed later.
string legacyFile = Path.Combine(guiFolder, "metadata.json"); string legacyFile = Path.Combine(guiFolder, "metadata.json");
if (File.Exists(legacyFile) && !File.Exists(metadataFile)) if (File.Exists(legacyFile) && !File.Exists(metadataFile))
{ {
File.Move(legacyFile, metadataFile); File.Move(legacyFile, metadataFile);
} }
// Create metadata file if it doesn't exist yet // Create metadata file if it doesn't exist yet.
ApplicationMetadata appMetadata; ApplicationMetadata appMetadata;
if (!File.Exists(metadataFile)) if (!File.Exists(metadataFile))
@ -533,7 +533,7 @@ namespace Ryujinx.Ui.App.Common
JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata); JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata);
} }
// Read from the metadata file // Read from the metadata file.
try try
{ {
appMetadata = JsonHelper.DeserializeFromFile(metadataFile, SerializerContext.ApplicationMetadata); appMetadata = JsonHelper.DeserializeFromFile(metadataFile, SerializerContext.ApplicationMetadata);
@ -545,7 +545,7 @@ namespace Ryujinx.Ui.App.Common
appMetadata = new ApplicationMetadata(); appMetadata = new ApplicationMetadata();
} }
// Modify the metadata and save it back to the file // Modify the metadata and save it back to the file.
if (modifyFunction != null) if (modifyFunction != null)
{ {
modifyFunction(appMetadata); modifyFunction(appMetadata);