@inherits LocalizableComponentBase @* Who may quote one of the persona's own public or unlisted posts (PUT /api/v1/statuses/:id/interaction_policy, quote_approval_policy): anyone, its followers or nobody, from the card's menu. The post states its policy in quote_approval.automatic; PrivaPub tells the post's readers of the change. *@ @Localizer["Who may quote it"]
@foreach (var policy in Enum.GetValues()) { @PolicyName(policy) @if (policy == current) { } }
@code { [Inject] StatusService StatusService { get; set; } [Parameter, EditorRequired] public Status Status { get; set; } [Parameter] public EventCallback OnClosed { get; set; } /// The post as PrivaPub now describes it, its new policy in it. [Parameter] public EventCallback OnChanged { get; set; } QuotePolicy current = QuotePolicy.Public; bool isSaving; protected override void OnInitialized() { current = StatusService.QuotePolicyOf(Status); IsLoading = false; } string PolicyName(QuotePolicy policy) => policy switch { QuotePolicy.Followers => Localizer["Your followers"], QuotePolicy.Nobody => Localizer["Nobody"], _ => Localizer["Anyone"] }; static string PolicyIcon(QuotePolicy policy) => policy switch { QuotePolicy.Followers => "ion-md-people", QuotePolicy.Nobody => "ion-md-close-circle", _ => "ion-md-globe" }; async Task Choose(QuotePolicy policy) { if (policy == current) return; isSaving = true; var result = await StatusService.SetQuotePolicy(Status.Id, policy); isSaving = false; if (result.IsInvalid) { Toast.AddResponseError(result); return; } var updated = (Status)result.Data; current = StatusService.QuotePolicyOf(updated); Toast.AddResponseSuccess(Localizer["Saved."]); await OnChanged.InvokeAsync(updated); } Task Closed(bool open) => open ? Task.CompletedTask : OnClosed.InvokeAsync(); }