< Summary

Information
Class: Chronicis.Client.Services.ITreeStateService
Assembly: Chronicis.Client
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/ITreeStateService.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 1
Coverable lines: 1
Total lines: 186
Line coverage: 0%
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
get_SelectedArticleId()100%210%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/ITreeStateService.cs

#LineLine coverage
 1using Chronicis.Client.Models;
 2using Chronicis.Shared.DTOs;
 3using Chronicis.Shared.Enums;
 4
 5namespace Chronicis.Client.Services;
 6
 7/// <summary>
 8/// Service for managing the article tree navigation state.
 9/// This is the single source of truth for all tree-related UI state.
 10/// </summary>
 11public interface ITreeStateService
 12{
 13    // ============================================
 14    // State Properties
 15    // ============================================
 16
 17    /// <summary>
 18    /// Root-level nodes of the tree.
 19    /// </summary>
 20    IReadOnlyList<TreeNode> RootNodes { get; }
 21
 22    /// <summary>
 23    /// Currently selected node ID.
 24    /// </summary>
 25    Guid? SelectedNodeId { get; }
 26
 27    /// <summary>
 28    /// Alias for SelectedNodeId for backwards compatibility.
 29    /// </summary>
 030    Guid? SelectedArticleId => SelectedNodeId;
 31
 32    /// <summary>
 33    /// Current search/filter query.
 34    /// </summary>
 35    string SearchQuery { get; }
 36
 37    /// <summary>
 38    /// Whether a search filter is currently active.
 39    /// </summary>
 40    bool IsSearchActive { get; }
 41
 42    /// <summary>
 43    /// Whether the tree is currently loading.
 44    /// </summary>
 45    bool IsLoading { get; }
 46
 47    /// <summary>
 48    /// Flag indicating the title field should be focused when loading an article.
 49    /// Used when creating new articles.
 50    /// </summary>
 51    bool ShouldFocusTitle { get; set; }
 52
 53    /// <summary>
 54    /// Exposes the cached article list for other services/components to consume.
 55    /// Avoids duplicate API calls from Dashboard, etc.
 56    /// </summary>
 57    IReadOnlyList<ArticleTreeDto> CachedArticles { get; }
 58
 59    /// <summary>
 60    /// Indicates whether the tree has been initialized and CachedArticles is populated.
 61    /// </summary>
 62    bool HasCachedData { get; }
 63
 64    // ============================================
 65    // Events
 66    // ============================================
 67
 68    /// <summary>
 69    /// Fired when any tree state changes. Components should re-render.
 70    /// </summary>
 71    event Action? OnStateChanged;
 72
 73    // ============================================
 74    // Initialization
 75    // ============================================
 76
 77    /// <summary>
 78    /// Initialize the tree by loading all articles.
 79    /// </summary>
 80    Task InitializeAsync();
 81
 82    /// <summary>
 83    /// Refresh the tree from the server.
 84    /// </summary>
 85    Task RefreshAsync();
 86
 87    // ============================================
 88    // Node Operations
 89    // ============================================
 90
 91    /// <summary>
 92    /// Expand a node to show its children.
 93    /// </summary>
 94    void ExpandNode(Guid nodeId);
 95
 96    /// <summary>
 97    /// Collapse a node to hide its children.
 98    /// </summary>
 99    void CollapseNode(Guid nodeId);
 100
 101    /// <summary>
 102    /// Toggle a node's expanded state.
 103    /// </summary>
 104    void ToggleNode(Guid nodeId);
 105
 106    /// <summary>
 107    /// Select a node.
 108    /// </summary>
 109    void SelectNode(Guid nodeId);
 110
 111    /// <summary>
 112    /// Expand the path to a node and select it.
 113    /// Used when navigating to an article from outside the tree.
 114    /// </summary>
 115    void ExpandPathToAndSelect(Guid nodeId);
 116
 117    // ============================================
 118    // CRUD Operations
 119    // ============================================
 120
 121    /// <summary>
 122    /// Create a new root-level article.
 123    /// </summary>
 124    Task<Guid?> CreateRootArticleAsync();
 125
 126    /// <summary>
 127    /// Create a new child article under the specified parent.
 128    /// </summary>
 129    Task<Guid?> CreateChildArticleAsync(Guid parentId);
 130
 131    /// <summary>
 132    /// Delete an article and all its descendants.
 133    /// </summary>
 134    Task<bool> DeleteArticleAsync(Guid articleId);
 135
 136    /// <summary>
 137    /// Move an article to a new parent (or to root if newParentId is null).
 138    /// </summary>
 139    Task<bool> MoveArticleAsync(Guid articleId, Guid? newParentId);
 140
 141    /// <summary>
 142    /// Update a node's display properties (title, icon) after an article is saved.
 143    /// </summary>
 144    void UpdateNodeDisplay(Guid nodeId, string title, string? iconEmoji);
 145
 146    /// <summary>
 147    /// Update a node's visibility after privacy is toggled.
 148    /// </summary>
 149    void UpdateNodeVisibility(Guid nodeId, ArticleVisibility visibility);
 150
 151    // ============================================
 152    // Search/Filter
 153    // ============================================
 154
 155    /// <summary>
 156    /// Set the search query and filter the tree.
 157    /// </summary>
 158    void SetSearchQuery(string query);
 159
 160    /// <summary>
 161    /// Clear the search filter.
 162    /// </summary>
 163    void ClearSearch();
 164
 165    // ============================================
 166    // Persistence
 167    // ============================================
 168
 169    /// <summary>
 170    /// Get the IDs of all currently expanded nodes.
 171    /// </summary>
 172    IReadOnlySet<Guid> GetExpandedNodeIds();
 173
 174    /// <summary>
 175    /// Restore expanded state from a saved set of IDs.
 176    /// </summary>
 177    void RestoreExpandedNodes(IEnumerable<Guid> nodeIds);
 178
 179    /// <summary>
 180    /// Try to get a node by its ID.
 181    /// </summary>
 182    /// <param name="nodeId">The node ID to look up.</param>
 183    /// <param name="node">The node if found, null otherwise.</param>
 184    /// <returns>True if the node was found, false otherwise.</returns>
 185    bool TryGetNode(Guid nodeId, out TreeNode? node);
 186}

Methods/Properties

get_SelectedArticleId()