From 34caee585f2409a5f8535ed7a1c44d51393c1322 Mon Sep 17 00:00:00 2001 From: Gordon Pedersen Date: Mon, 24 Jun 2024 10:40:46 +1000 Subject: [PATCH] Better now edit submit behaviour --- Components/Pages/EditNow.razor | 20 +++++++++++++++----- RestService.cs | 1 - 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Components/Pages/EditNow.razor b/Components/Pages/EditNow.razor index 67ef8a3..6cf9b2d 100644 --- a/Components/Pages/EditNow.razor +++ b/Components/Pages/EditNow.razor @@ -25,10 +25,11 @@ @code { - MarkdownEditor Editor; - bool listed; - string markdownValue; - string markdownHtml; + private MarkdownEditor Editor; + private bool listed; + private string markdownValue; + + private bool loading = false; protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); @@ -47,6 +48,15 @@ } public async Task Save() { - await api.PostNowPage(State.SelectedAddressName, markdownValue, listed); + loading = true; + await InvokeAsync(StateHasChanged); + var result = await api.PostNowPage(State.SelectedAddressName, markdownValue, listed); + if (result != null) { + await State.RefreshNow(); + await InvokeAsync(StateHasChanged); + Nav.NavigateTo($"/person/{State.SelectedAddressName}#now"); + } + + loading = false; } } diff --git a/RestService.cs b/RestService.cs index 874d6b7..90f63ae 100644 --- a/RestService.cs +++ b/RestService.cs @@ -198,7 +198,6 @@ namespace Neighbourhood.omg.lol { public async Task DeletePic(string address, string id) => (await Delete($"/address/{address}/pics/{id}")); - public async Task PatchStatus(string address, string id, string content, string? emoji) => (await Patch($"/address/{address}/statuses/", new PatchStatus { Id = id, Content = content, Emoji = emoji }));