Refactored archive uploader to use binding instead of Game parameter

May fix issues where game metadata is wiped after uploading an archive.
redistributables
Pat Hartl 2023-10-18 18:11:20 -05:00
parent 539ddb2f2e
commit 2287ac9922
2 changed files with 8 additions and 9 deletions

View File

@ -11,7 +11,7 @@
<Space Direction="DirectionVHType.Vertical" Style="width: 100%">
<SpaceItem>
<Table TItem="Archive" DataSource="@Game.Archives.OrderByDescending(a => a.CreatedOn)" HidePagination="true" Responsive>
<Table TItem="Archive" DataSource="@Archives.OrderByDescending(a => a.CreatedOn)" HidePagination="true" Responsive>
<PropertyColumn Property="a => a.Version" />
<PropertyColumn Property="a => a.CompressedSize">
@ByteSizeLib.ByteSize.FromBytes(context.CompressedSize)
@ -49,7 +49,9 @@
<ArchiveUploader @ref="Uploader" OnArchiveUploaded="AddArchive" />
@code {
[Parameter] public Game Game { get; set; }
[Parameter] public Guid GameId { get; set; }
[Parameter] public ICollection<Archive> Archives { get; set; }
[Parameter] public EventCallback<ICollection<Archive>> ArchivesChanged { get; set; }
Archive Archive;
ArchiveUploader Uploader;
@ -63,10 +65,7 @@
private async Task LoadData()
{
Game.Archives = await ArchiveService.Get(a => a.GameId == Game.Id).OrderByDescending(a => a.CreatedOn).ToListAsync();
if (Game.Archives == null)
Game.Archives = new List<Archive>();
Archives = await ArchiveService.Get(a => a.GameId == GameId).OrderByDescending(a => a.CreatedOn).ToListAsync();
}
private async Task Download(Archive archive)
@ -80,7 +79,7 @@
{
Archive = new Archive()
{
GameId = Game.Id,
GameId = GameId,
Id = Guid.NewGuid()
};
@ -89,7 +88,7 @@
private async Task AddArchive(Archive archive)
{
var lastArchive = Game.Archives.OrderByDescending(a => a.CreatedOn).FirstOrDefault();
var lastArchive = Archives.OrderByDescending(a => a.CreatedOn).FirstOrDefault();
Archive = await ArchiveService.Add(archive);

View File

@ -125,7 +125,7 @@
</div>
<div data-panel="Archives">
<ArchiveEditor Game="Game" />
<ArchiveEditor @bind-Archives="Game.Archives" GameId="Game.Id" />
</div>
}