Files
decePubClient/Components/PublicNoticeHost.razor
T

57 lines
2.4 KiB
Plaintext
Raw Normal View History

@inherits LocalizableComponentBase
@implements IDisposable
@* The one-time notice before a persona's first reaction or poll vote, before it first joins an event, and before this
device's first Web Push subscription (PublicNoticeService), in MainLayout. data-public-notice names which. *@
<DModal Placement="DModalPlacement.ResponsiveBottom" IsOpen="Notices.IsAsking" IsOpenChanged="Closed" CloseOnBackdrop="false" CloseText="@Localizer["Close"]"
data-public-notice="@ActName">
<Heading>@HeadingText</Heading>
<ChildContent>
<p class="text-sm">@NoticeText</p>
</ChildContent>
<Actions>
<DButton Size="DSize.Sm" OnClick="() => Notices.Answer(false)">@Localizer["Cancel"]</DButton>
<DButton Size="DSize.Sm" Color="DColor.Primary" OnClick="() => Notices.Answer(true)" data-public-notice-yes>@Localizer["Continue"]</DButton>
</Actions>
</DModal>
@code {
[Inject] PublicNoticeService Notices { get; set; }
string ActName => Notices.Act switch
{
PublicAct.Participation => "participation",
PublicAct.Push => "push",
_ => "reaction"
};
string HeadingText => Notices.Act switch
{
PublicAct.Participation => Localizer["Joining an event is public"],
PublicAct.Push => Localizer["Notifications go through your browser's push service"],
_ => Localizer["Reactions and votes are public"]
};
string NoticeText => Notices.Act switch
{
PublicAct.Participation => Localizer["The event's server shows who takes part, {0} included. Your other personas are never named.", CascadingState.Persona?.Name ?? ""],
PublicAct.Push => Localizer["To reach this device while decePub is closed, PrivaPub hands each notification to the push service your browser uses (Google's, Mozilla's, Apple's…). It is encrypted for this browser alone: the push service learns when a notification arrives and how big it is, never what it says, who sent it or which persona it is for. Each persona has a subscription of its own, so PrivaPub keeps nothing that ties your personas together."],
_ => Localizer["Anyone who can see the post can see that {0} reacted to it or voted in it. Your other personas are never named.", CascadingState.Persona?.Name ?? ""]
};
protected override void OnInitialized()
{
Notices.Changed += Refresh;
IsLoading = false;
}
void Refresh() => InvokeAsync(StateHasChanged);
void Closed(bool open)
{
if (!open)
Notices.Answer(false);
}
public void Dispose() => Notices.Changed -= Refresh;
}