From 2287ac99221b956eb665dcbb3ce5ba6e3bbbef0e Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Wed, 18 Oct 2023 18:11:20 -0500 Subject: [PATCH] Refactored archive uploader to use binding instead of Game parameter May fix issues where game metadata is wiped after uploading an archive. --- LANCommander/Components/ArchiveEditor.razor | 15 +++++++-------- LANCommander/Pages/Games/Edit.razor | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/LANCommander/Components/ArchiveEditor.razor b/LANCommander/Components/ArchiveEditor.razor index 221d371..2f7b3c7 100644 --- a/LANCommander/Components/ArchiveEditor.razor +++ b/LANCommander/Components/ArchiveEditor.razor @@ -11,7 +11,7 @@ - +
@ByteSizeLib.ByteSize.FromBytes(context.CompressedSize) @@ -49,7 +49,9 @@ @code { - [Parameter] public Game Game { get; set; } + [Parameter] public Guid GameId { get; set; } + [Parameter] public ICollection Archives { get; set; } + [Parameter] public EventCallback> 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(); + 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); diff --git a/LANCommander/Pages/Games/Edit.razor b/LANCommander/Pages/Games/Edit.razor index c2f3a8f..13d9489 100644 --- a/LANCommander/Pages/Games/Edit.razor +++ b/LANCommander/Pages/Games/Edit.razor @@ -125,7 +125,7 @@
- +
}