diff --git a/src/NexusReader.Application/Commands/Sync/UpdateReadingProgressCommand.cs b/src/NexusReader.Application/Commands/Sync/UpdateReadingProgressCommand.cs index 8310339..2c6a4a2 100644 --- a/src/NexusReader.Application/Commands/Sync/UpdateReadingProgressCommand.cs +++ b/src/NexusReader.Application/Commands/Sync/UpdateReadingProgressCommand.cs @@ -3,4 +3,4 @@ using MediatR; namespace NexusReader.Application.Commands.Sync; -public record UpdateReadingProgressCommand(string PageId, string UserId) : IRequest; +public record UpdateReadingProgressCommand(string PageId, string UserId, string? ExcludedConnectionId = null) : IRequest; diff --git a/src/NexusReader.Infrastructure/Handlers/UpdateReadingProgressCommandHandler.cs b/src/NexusReader.Infrastructure/Handlers/UpdateReadingProgressCommandHandler.cs index 1f5d82f..f82a82c 100644 --- a/src/NexusReader.Infrastructure/Handlers/UpdateReadingProgressCommandHandler.cs +++ b/src/NexusReader.Infrastructure/Handlers/UpdateReadingProgressCommandHandler.cs @@ -38,9 +38,18 @@ public class UpdateReadingProgressCommandHandler : IRequestHandler RequestSummaryAndQuizAsync(string content, string tenantId = "global") { - _quizService.SetHydrating(true); + await _quizService.SetHydrating(true); LogRequestingSummary(tenantId); try { @@ -91,7 +91,7 @@ public sealed partial class KnowledgeCoordinator : IDisposable .Select(q => new QuizQuestionDto(q.Question, q.Options, q.CorrectIndex)) .ToList(); - _quizService.SetQuiz(null, new QuizDto(quizQuestions)); + await _quizService.SetQuiz(null, new QuizDto(quizQuestions)); await _platformService.VibrateSuccessAsync(); return packet; } @@ -104,7 +104,7 @@ public sealed partial class KnowledgeCoordinator : IDisposable } finally { - _quizService.SetHydrating(false); + await _quizService.SetHydrating(false); } return null; } @@ -112,7 +112,7 @@ public sealed partial class KnowledgeCoordinator : IDisposable public async Task ClearAsync() { await _graphService.Clear(); - _quizService.SetQuiz(null, null); + await _quizService.SetQuiz(null, null); } public void Dispose() diff --git a/src/NexusReader.UI.Shared/wwwroot/js/knowledgeGraph.js b/src/NexusReader.UI.Shared/wwwroot/js/knowledgeGraph.js index 8119ff0..42aa778 100644 --- a/src/NexusReader.UI.Shared/wwwroot/js/knowledgeGraph.js +++ b/src/NexusReader.UI.Shared/wwwroot/js/knowledgeGraph.js @@ -1,5 +1,8 @@ import * as d3 from 'https://esm.sh/d3@7'; +const getDisplayLabel = d => d.label.length > 20 ? d.label.substring(0, 17) + "..." : d.label; +const getPillWidth = d => getDisplayLabel(d).length * 8 + 30; + let simulation; let zoomBehavior; let svgElement; @@ -73,7 +76,7 @@ export function mount(containerId, data, dotNetHelper) { .force("link", d3.forceLink().id(d => d.id).distance(120)) .force("charge", d3.forceManyBody().strength(-400)) .force("center", d3.forceCenter(width / 2, height / 2)) - .force("collide", d3.forceCollide().radius(50)); + .force("collide", d3.forceCollide().radius(d => (getPillWidth(d) / 2) + 20)); simulation.on("tick", () => { if (link) { @@ -168,11 +171,11 @@ export function updateData(data) { g.append("rect") .attr("class", "node-pill") - .attr("x", d => -(d.label.length * 4 + 10)) - .attr("y", -12) - .attr("width", d => d.label.length * 8 + 20) - .attr("height", 24) - .attr("rx", 12) + .attr("x", d => -getPillWidth(d) / 2) + .attr("y", -15) + .attr("width", d => getPillWidth(d)) + .attr("height", 30) + .attr("rx", 15) .attr("fill", "rgba(20, 20, 20, 0.9)") .attr("stroke", d => { if (d.type === 'Definition') return 'var(--nexus-accent)'; @@ -182,11 +185,14 @@ export function updateData(data) { .attr("stroke-width", 1); g.append("text") - .text(d => d.label) + .text(d => getDisplayLabel(d)) .attr("text-anchor", "middle") - .attr("y", 4) + .attr("y", 5) .attr("fill", d => d.type === 'Definition' ? 'var(--nexus-accent)' : '#ccc') .attr("font-size", "0.8rem"); + + g.append("title") + .text(d => d.label); g.transition().duration(500).style("opacity", 1);