< Summary

Information
Class: Syki.Front.Features.Cross.GetUserNotifications.NotificationsIconButton
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Features/Cross/GetUserNotifications/NotificationsIconButton.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 24
Coverable lines: 24
Total lines: 62
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
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%
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        <MudIconButton OnClick="@ViewAndOpenDialog" Color="Color.Error" Icon="@Icons.Material.Filled.NotificationsActive
 9    }
 10    else
 11    {
 12        <MudIconButton Icon="@Icons.Material.Filled.NotificationsNone" OnClick="@OpenDialog" Color="Color.Inherit" />
 13    }
 14</div>
 15
 16@inject IDialogService DialogService
 17@inject IBrowserViewportService BrowserViewportService
 18@inject ViewNotificationsClient ViewNotificationsClient
 19@inject GetUserNotificationsClient GetUserNotificationsClient
 20
 21@code
 22{
 23    private bool _alert = false;
 024    private List<UserNotificationOut> _notifications = [];
 25
 26    protected override async Task OnInitializedAsync()
 27    {
 028        await GetNotifications();
 029        _alert = _notifications.Any(x => x.ViewedAt == null);
 030    }
 31
 32    private async Task GetNotifications()
 33    {
 034        _notifications = await GetUserNotificationsClient.Get();
 035    }
 36
 37    private async Task ViewAndOpenDialog()
 38    {
 039        _alert = false;
 040        await OpenDialog();
 041        await ViewNotificationsClient.View();
 042        await GetNotifications();
 043        StateHasChanged();
 044    }
 45
 46    private async Task OpenDialog()
 47    {
 048        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 049        var options = new DialogOptions {
 050            MaxWidth = MaxWidth.Medium,
 051            FullWidth = true,
 052            FullScreen = breakpoint == Breakpoint.Xs,
 053        };
 054        var dialog = await DialogService.ShowAsync<ViewNotificationsDialog>("", options);
 55
 056        var result = await dialog.Result;
 57
 058        if (result!.Canceled) return;
 59
 060        await GetNotifications();
 061    }
 62}