@inject IJSRuntime JS @inject State State
@code { private Status? _status; public Status? Status { get => _status; set { _status = value; Content = _status?.Content; Emoji = _status?.Emoji; InvokeAsync(StateHasChanged); } } public string? Content { get; set; } public string? Emoji { get; set; } private bool loading = false; [Parameter] public string id { get; set; } protected override async Task OnInitializedAsync() { Content = Status?.Content; Emoji = Status?.Emoji; } public async Task PatchStatus() { loading = true; await InvokeAsync(StateHasChanged); RestService api = new RestService(); if (!string.IsNullOrEmpty(Status?.Id)) { await api.PatchStatus(State.SelectedAddressName, Status.Id, Content, Emoji); await State.RefreshStatuses(); await InvokeAsync(StateHasChanged); } await JS.InvokeVoidAsync("ui", "#" + id); // clear input Content = string.Empty; Emoji = string.Empty; Status = null; loading = false; await InvokeAsync(StateHasChanged); } }