< Summary

Information
Class: Pomodoro.Web.Services.InfiniteScrollInterop
Assembly: Pomodoro.Web
File(s): /home/runner/work/Pomodoro/Pomodoro/src/Pomodoro.Web/Services/InfiniteScrollInterop.cs
Line coverage
100%
Covered lines: 40
Uncovered lines: 0
Coverable lines: 40
Total lines: 88
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
IsSupportedAsync()100%11100%
CreateObserverAsync()100%11100%
DestroyObserverAsync()100%11100%
DestroyAllObserversAsync()100%11100%

File(s)

/home/runner/work/Pomodoro/Pomodoro/src/Pomodoro.Web/Services/InfiniteScrollInterop.cs

#LineLine coverage
 1using Microsoft.JSInterop;
 2
 3namespace Pomodoro.Web.Services;
 4
 5/// <summary>
 6/// Implementation of infinite scroll JavaScript interop operations.
 7/// Wraps IJSRuntime calls to enable mocking in unit tests.
 8/// </summary>
 9public class InfiniteScrollInterop : IInfiniteScrollInterop
 10{
 11    private readonly IJSRuntime _jsRuntime;
 12
 1813    public InfiniteScrollInterop(IJSRuntime jsRuntime)
 1814    {
 1815        _jsRuntime = jsRuntime;
 1816    }
 17
 18    /// <summary>
 19    /// Checks if the Intersection Observer API is supported in the browser.
 20    /// </summary>
 21    public async Task<bool> IsSupportedAsync()
 322    {
 23        try
 324        {
 325            return await _jsRuntime.InvokeAsync<bool>("infiniteScroll.isSupported");
 26        }
 127        catch (JSException)
 128        {
 129            return false;
 30        }
 331    }
 32
 33    /// <summary>
 34    /// Creates an Intersection Observer for the infinite scroll sentinel element.
 35    /// </summary>
 36    public async Task<bool> CreateObserverAsync(
 37        string sentinelId,
 38        DotNetObjectReference<object> dotNetRef,
 39        string containerId,
 40        string rootMargin,
 41        int timeoutMs)
 442    {
 43        try
 444        {
 445            return await _jsRuntime.InvokeAsync<bool>(
 446                "infiniteScroll.createObserver",
 447                sentinelId,
 448                dotNetRef,
 449                containerId,
 450                rootMargin,
 451                timeoutMs);
 52        }
 153        catch (JSException)
 154        {
 155            return false;
 56        }
 457    }
 58
 59    /// <summary>
 60    /// Destroys the Intersection Observer for a specific sentinel element.
 61    /// </summary>
 62    public async Task DestroyObserverAsync(string sentinelId)
 363    {
 64        try
 365        {
 366            await _jsRuntime.InvokeVoidAsync("infiniteScroll.destroyObserver", sentinelId);
 267        }
 168        catch (JSException)
 169        {
 70            // Silently handle errors during cleanup
 171        }
 372    }
 73
 74    /// <summary>
 75    /// Destroys all Intersection Observers (fallback cleanup).
 76    /// </summary>
 77    public async Task DestroyAllObserversAsync()
 278    {
 79        try
 280        {
 281            await _jsRuntime.InvokeVoidAsync("infiniteScroll.destroyAllObservers");
 182        }
 183        catch (JSException)
 184        {
 85            // Silently handle errors during cleanup
 186        }
 287    }
 88}