< Summary - Syki

Information
Class: Syki.Front.Features.Cross.GetUserNotifications.NotificationsIconButton
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Features/Cross/GetUserNotifications/NotificationsIconButton.razor
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 25
Coverable lines: 25
Total lines: 69
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
BuildRenderTree(...)0%620%
.ctor()100%210%
OnInitializedAsync()100%210%
GetCount()0%620%
GetNotifications()100%210%
ViewAndOpenDialog()100%210%
OpenDialog()0%620%

File(s)

/home/runner/work/syki/syki/Front/Features/Cross/GetUserNotifications/NotificationsIconButton.razor

#LineLine coverage
 1@using Syki.Front.Features.Cross.ViewNotifications
 2
 3@namespace Syki.Front.Features.Cross.GetUserNotifications
 4
 5<div>
 06    @if (_alert)
 7    {
 8        <MudBadge Content="@(GetCount())" Color="Color.Error" Overlap="true" BadgeClass="syki-badge-icon">
 9            <MudIconButton OnClick="@ViewAndOpenDialog" Icon="@Icons.Material.Filled.NotificationsActive" Style="color: 
 10        </MudBadge>
 11    }
 12    else
 13    {
 14        <MudIconButton Icon="@Icons.Material.Filled.NotificationsNone" OnClick="@OpenDialog" Color="Color.Inherit" />
 15    }
 16</div>
 17
 18@inject IDialogService DialogService
 19@inject IBrowserViewportService BrowserViewportService
 20@inject ViewNotificationsClient ViewNotificationsClient
 21@inject GetUserNotificationsClient GetUserNotificationsClient
 22
 23@code
 24{
 25    private bool _alert = false;
 026    private List<UserNotificationOut> _notifications = [];
 27
 28    protected override async Task OnInitializedAsync()
 29    {
 030        await GetNotifications();
 031        _alert = _notifications.Any(x => x.ViewedAt == null);
 032    }
 33
 34    private string GetCount()
 35    {
 036        return _notifications.Count < 10 ? _notifications.Count.ToString() : "9+";
 37    }
 38
 39    private async Task GetNotifications()
 40    {
 041        _notifications = await GetUserNotificationsClient.Get();
 042    }
 43
 44    private async Task ViewAndOpenDialog()
 45    {
 046        _alert = false;
 047        await OpenDialog();
 048        await ViewNotificationsClient.View();
 049        await GetNotifications();
 050        StateHasChanged();
 051    }
 52
 53    private async Task OpenDialog()
 54    {
 055        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 056        var options = new DialogOptions {
 057            MaxWidth = MaxWidth.Medium,
 058            FullWidth = true,
 059            FullScreen = breakpoint == Breakpoint.Xs,
 060        };
 061        var dialog = await DialogService.ShowAsync<ViewNotificationsDialog>("", options);
 62
 063        var result = await dialog.Result;
 64
 065        if (result!.Canceled) return;
 66
 067        await GetNotifications();
 068    }
 69}