Ava UI: Various Fixes (#4326)

* Ava UI: Various Fixes

* use WriteAllBytes
This commit is contained in:
Ac_K 2023-01-22 01:42:55 +01:00 committed by GitHub
parent 7fea26e97e
commit c14844d12c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 88 additions and 74 deletions

View file

@ -21,8 +21,9 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SpanHelpers = LibHac.Common.SpanHelpers;
using System.Text;
using Path = System.IO.Path;
using SpanHelpers = LibHac.Common.SpanHelpers;
namespace Ryujinx.Ava.UI.ViewModels;
@ -90,6 +91,8 @@ public class TitleUpdateViewModel : BaseModel
Selected = "",
Paths = new List<string>()
};
Save();
}
LoadUpdates();
@ -102,6 +105,9 @@ public class TitleUpdateViewModel : BaseModel
AddUpdate(path);
}
// NOTE: Save the list again to remove leftovers.
Save();
TitleUpdateModel selected = TitleUpdates.FirstOrDefault(x => x.Path == _titleUpdateWindowData.Selected, null);
SelectedUpdate = selected;
@ -223,4 +229,22 @@ public class TitleUpdateViewModel : BaseModel
SortUpdates();
}
public void Save()
{
_titleUpdateWindowData.Paths.Clear();
_titleUpdateWindowData.Selected = "";
foreach (TitleUpdateModel update in TitleUpdates)
{
_titleUpdateWindowData.Paths.Add(update.Path);
if (update == SelectedUpdate)
{
_titleUpdateWindowData.Selected = update.Path;
}
}
File.WriteAllBytes(_titleUpdateJsonPath, Encoding.UTF8.GetBytes(JsonHelper.Serialize(_titleUpdateWindowData, true)));
}
}