@inherits Fluxor.Blazor.Web.Components.FluxorComponent @using Fluxor @using Koogle.Application.DTOs @using Koogle.Application.Interfaces @using Koogle.Domain.Enums @using Koogle.Web.Store.GifState @inject IClubTerminologyService Terms @inject IState GifState @inject IDispatcher Dispatcher @if (GifState.Value.IsPlaying && GifState.Value.CurrentGif != null) {
@if (IsVideo) { } else { @GifState.Value.CurrentGif.Name }
@GetEventDisplayName(GifState.Value.TriggerEvent) @GifState.Value.CurrentGif.Name
@if (ShowRating) {
}
} @code { private ElementReference _videoElement; [Parameter] public bool ShowRating { get; set; } = true; [Parameter] public Guid? UserProfileId { get; set; } private bool IsVideo => GifState.Value.CurrentGif?.ContentType.StartsWith("video/") ?? false; private void DismissGif() { Dispatcher.Dispatch(new EndGifPlaybackAction()); } private void RateGif(int value) { if (UserProfileId.HasValue && GifState.Value.CurrentGif != null) { Dispatcher.Dispatch(new RateCurrentGifAction(UserProfileId.Value, value)); } DismissGif(); } private string _termNoWood = "PUDEL!"; private string _termGutter = "RINNE!"; private string _termBell = "GLOCKE!"; protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { var noWood = await Terms.GetTermAsync(TermKey.NoWood); _termNoWood = $"{noWood.ToUpper()}!"; var gutter = await Terms.GetTermAsync(TermKey.Gutter); _termGutter = $"{gutter.ToUpper()}!"; var bell = await Terms.GetTermAsync(TermKey.Gutter); _termBell = $"{bell.ToUpper()}!"; StateHasChanged(); } } private string GetEventDisplayName(ThrowEventType? eventType) => eventType switch { ThrowEventType.Strike => "ALLE NEUNE!", ThrowEventType.Circle => "KRANZ!", ThrowEventType.Bell => _termBell, ThrowEventType.Gutter => _termGutter, ThrowEventType.NoWood => _termNoWood, ThrowEventType.Cleared => "ABGERÄUMT!", _ => "" }; }