using NexusReader.Application.Queries.Graph; namespace NexusReader.UI.Shared.Services; public sealed class KnowledgeGraphService : IKnowledgeGraphService { public GraphDataDto? CurrentGraphData { get; private set; } public string? ActiveNodeId { get; private set; } public bool IsLoading { get; private set; } public event Action? OnGraphUpdated; public event Action? OnActiveNodeChanged; public event Action? OnLoadingChanged; public void UpdateGraph(GraphDataDto newData) { CurrentGraphData = newData; IsLoading = false; OnLoadingChanged?.Invoke(false); OnGraphUpdated?.Invoke(); } public void SetActiveNode(string nodeId) { if (ActiveNodeId == nodeId) return; ActiveNodeId = nodeId; OnActiveNodeChanged?.Invoke(nodeId); } public void SetLoading(bool isLoading) { IsLoading = isLoading; OnLoadingChanged?.Invoke(isLoading); } public void Clear() { CurrentGraphData = null; ActiveNodeId = null; IsLoading = false; OnGraphUpdated?.Invoke(); } }