From d3d926875f137b3b25d7a2beee14e5d73ca9aab9 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Fri, 8 Sep 2023 09:03:58 +1000 Subject: Additional data sanitization in media service and keyboard shortcuts --- Pages/ViewMedia.razor | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'Pages/ViewMedia.razor') diff --git a/Pages/ViewMedia.razor b/Pages/ViewMedia.razor index 26b7988..7823c75 100644 --- a/Pages/ViewMedia.razor +++ b/Pages/ViewMedia.razor @@ -4,7 +4,6 @@ @inject IDbContextFactory dbFactory @inject ITagService tagService @inject IMediaService mediaService -@implements IDisposable @title @@ -30,7 +29,7 @@ - + @@ -83,19 +82,19 @@
- - - + + + @if(infoEditMode) { } else { - + } @if(media.IsIngest) { - + } else { - + }
@@ -143,14 +142,18 @@ private Dialog ocrDialog; private TagSelectDialog tagDialog; - private HBContext db; + private ElementReference shortDescriptionInput; - protected override void OnInitialized() { - db = dbFactory.CreateDbContext(); + protected override void OnInitialized() => LoadMedia(); + + protected override async void OnAfterRender(bool firstRender) { + if(infoEditMode) + await shortDescriptionInput.FocusAsync(); } private void LoadMedia() { + using var db = dbFactory.CreateDbContext(); media = db.Media .Include(m => m.Tags) .ThenInclude(t => t.TagDefinition) @@ -170,7 +173,6 @@ private async void SetIngest(bool ingest) { mediaService.SetIngest(media, ingest); - db.Entry(media).State = EntityState.Detached; LoadMedia(); if(ingest) @@ -191,11 +193,8 @@ private void ApplyInfoEdit(bool apply) { if(apply) { - if(string.IsNullOrEmpty(shortDescription)) shortDescription = null; - if(string.IsNullOrEmpty(longDescription)) longDescription = null; - media.ShortDescription = shortDescription; - media.LongDescription = longDescription; mediaService.SetDescription(media, shortDescription, longDescription); + LoadMedia(); } infoEditMode = false; @@ -205,6 +204,4 @@ mediaService.Delete(media); await jsRuntime.InvokeVoidAsync("history.back"); } - - public void Dispose() => db.Dispose(); } -- cgit v1.3
Title:
Description: