@inject IJSRuntime JS @inject State State @inject RestService api @inject NavigationManager navigationManager @inject NavigatorService navigatorService
@code { [Parameter] public string? id { get; set; } [Parameter] public bool Active { get; set; } [Parameter] public string Content { get; set; } = string.Empty; [Parameter] public string? Emoji { get; set; } = null; [Parameter] public bool postToMastodon { get; set; } = true; private bool loading = false; public async Task PostStatus() { StatusPost post = new StatusPost { Emoji = Emoji, Content = Content }; if (State?.SelectedAddress?.Preferences?.Statuslog?.MastodonPosting ?? false) { post.SkipMastodonPost = !postToMastodon; } if(Content.Length >= 500) { bool answer = await navigatorService.Page!.DisplayAlert( "Character limit reached", "Your message is over 500 characters, which is a lot for a status.\n" + ((postToMastodon && !(post.SkipMastodonPost ?? true))? "If you continue, your post will not make it over to Mastodon.\n" : "") + "Do you wish to post it anyway?", "Yes", "No" ); if (!answer) return; } loading = true; await InvokeAsync(StateHasChanged); var result = await api.StatusPost(State!.SelectedAddressName!, post); if(result != null){ await State.RefreshStatuses(); State.SendRefresh(); await InvokeAsync(StateHasChanged); // navigationManager.NavigateTo("/statuslog/latest"); } this.Active = false; await JS.InvokeVoidAsync("ui", "#" + id); Content = string.Empty; Emoji = null; postToMastodon = true; loading = false; } }