diff --git a/docs/event-types-panel-redesign.org b/docs/event-types-panel-redesign.org index 1df0846..bb898dc 100644 --- a/docs/event-types-panel-redesign.org +++ b/docs/event-types-panel-redesign.org @@ -90,3 +90,16 @@ const contentEvents = await $ndkInstance.fetchEvents({ 3. **UX**: Smooth, instant toggle without freezing 4. **Maintainability**: Clear separation of concerns 5. **Scalability**: Handles large numbers of nodes efficiently + +* Additional Improvements + +** Profile Fetching Optimization +- When follow list limit is 0, only fetch profiles from event authors +- Excludes follow list pubkeys from profile fetching when not needed +- Reduces unnecessary network requests + +** Person Node Visual Distinction +- Green diamonds (#10B981) for authors of displayed events +- Kind 3 color for people from follow lists +- Visual clarity on social graph relationships +- Legend updates to match graph coloring diff --git a/src/lib/navigator/EventNetwork/utils/forceSimulation.ts b/src/lib/navigator/EventNetwork/utils/forceSimulation.ts index 50fc672..bb21ebb 100644 --- a/src/lib/navigator/EventNetwork/utils/forceSimulation.ts +++ b/src/lib/navigator/EventNetwork/utils/forceSimulation.ts @@ -102,8 +102,8 @@ export function applyGlobalLogGravity( centerY: number, alpha: number, ) { - // Tag anchors should not be affected by gravity - if (node.isTagAnchor) return; + // Tag anchors and person anchors should not be affected by gravity + if (node.isTagAnchor || node.isPersonAnchor) return; const dx = (node.x ?? 0) - centerX; const dy = (node.y ?? 0) - centerY; @@ -130,14 +130,14 @@ export function applyConnectedGravity( links: NetworkLink[], alpha: number, ) { - // Tag anchors should not be affected by connected gravity - if (node.isTagAnchor) return; + // Tag anchors and person anchors should not be affected by connected gravity + if (node.isTagAnchor || node.isPersonAnchor) return; - // Find all nodes connected to this node (excluding tag anchors) + // Find all nodes connected to this node (excluding tag anchors and person anchors) const connectedNodes = links .filter(link => link.source.id === node.id || link.target.id === node.id) .map(link => link.source.id === node.id ? link.target : link.source) - .filter(n => !n.isTagAnchor); + .filter(n => !n.isTagAnchor && !n.isPersonAnchor); if (connectedNodes.length === 0) return; @@ -175,8 +175,13 @@ export function setupDragHandlers( return d3 .drag() .on("start", (event: D3DragEvent, d: NetworkNode) => { - // Tag anchors should never be draggable - if (d.isTagAnchor) return; + // Tag anchors and person anchors retain their anchor behavior + if (d.isTagAnchor || d.isPersonAnchor) { + // Still allow dragging but maintain anchor status + d.fx = d.x; + d.fy = d.y; + return; + } // Warm up simulation if it's cooled down if (!event.active) { @@ -187,24 +192,29 @@ export function setupDragHandlers( d.fy = d.y; }) .on("drag", (event: D3DragEvent, d: NetworkNode) => { - // Tag anchors should never be draggable - if (d.isTagAnchor) return; + // Update position for all nodes including anchors // Update fixed position to mouse position d.fx = event.x; d.fy = event.y; }) .on("end", (event: D3DragEvent, d: NetworkNode) => { - // Tag anchors should never be draggable - if (d.isTagAnchor) return; // Cool down simulation when drag ends if (!event.active) { simulation.alphaTarget(0); } - // Release fixed position - d.fx = null; - d.fy = null; + + // Person anchors should remain fixed after dragging + if (d.isPersonAnchor) { + // Keep the new position fixed + d.fx = d.x; + d.fy = d.y; + } else { + // Release fixed position for other nodes + d.fx = null; + d.fy = null; + } }); } diff --git a/src/lib/navigator/EventNetwork/utils/starForceSimulation.ts b/src/lib/navigator/EventNetwork/utils/starForceSimulation.ts index a20cb07..7c52e8d 100644 --- a/src/lib/navigator/EventNetwork/utils/starForceSimulation.ts +++ b/src/lib/navigator/EventNetwork/utils/starForceSimulation.ts @@ -247,8 +247,8 @@ export function createStarDragHandler( function dragended(event: any, d: NetworkNode) { if (!event.active) simulation.alphaTarget(0); - // Tag anchors and star centers stay fixed after dragging - if (d.isTagAnchor || d.kind === 30040) { + // Tag anchors, person anchors, and star centers stay fixed after dragging + if (d.isTagAnchor || d.isPersonAnchor || d.kind === 30040) { d.fx = event.x; d.fy = event.y; } else {