|
|
|
|
@ -107,31 +107,19 @@ export function extractUniquePersons(
@@ -107,31 +107,19 @@ export function extractUniquePersons(
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Creates person anchor nodes |
|
|
|
|
* Helper to build eligible person info for anchor nodes. |
|
|
|
|
*/ |
|
|
|
|
export function createPersonAnchorNodes( |
|
|
|
|
personMap: Map<string, PersonConnection>, |
|
|
|
|
width: number, |
|
|
|
|
height: number, |
|
|
|
|
function buildEligiblePerson( |
|
|
|
|
pubkey: string, |
|
|
|
|
connection: PersonConnection, |
|
|
|
|
showSignedBy: boolean, |
|
|
|
|
showReferenced: boolean, |
|
|
|
|
limit: number = MAX_PERSON_NODES |
|
|
|
|
): { nodes: NetworkNode[], totalCount: number } { |
|
|
|
|
const anchorNodes: NetworkNode[] = []; |
|
|
|
|
|
|
|
|
|
const centerX = width / 2; |
|
|
|
|
const centerY = height / 2; |
|
|
|
|
|
|
|
|
|
// Calculate eligible persons and their connection counts
|
|
|
|
|
const eligiblePersons: Array<{ |
|
|
|
|
showReferenced: boolean |
|
|
|
|
): { |
|
|
|
|
pubkey: string; |
|
|
|
|
connection: PersonConnection; |
|
|
|
|
connectedEventIds: Set<string>; |
|
|
|
|
totalConnections: number; |
|
|
|
|
}> = []; |
|
|
|
|
|
|
|
|
|
Array.from(personMap.entries()).forEach(([pubkey, connection]) => { |
|
|
|
|
// Get all connected event IDs based on filters
|
|
|
|
|
} | null { |
|
|
|
|
const connectedEventIds = new Set<string>(); |
|
|
|
|
|
|
|
|
|
if (showSignedBy) { |
|
|
|
|
@ -142,16 +130,40 @@ export function createPersonAnchorNodes(
@@ -142,16 +130,40 @@ export function createPersonAnchorNodes(
|
|
|
|
|
connection.referencedInEventIds.forEach(id => connectedEventIds.add(id)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Skip if no connections match the filter
|
|
|
|
|
if (connectedEventIds.size === 0) return; |
|
|
|
|
if (connectedEventIds.size === 0) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
eligiblePersons.push({ |
|
|
|
|
return { |
|
|
|
|
pubkey, |
|
|
|
|
connection, |
|
|
|
|
connectedEventIds, |
|
|
|
|
totalConnections: connectedEventIds.size |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Creates person anchor nodes |
|
|
|
|
*/ |
|
|
|
|
export function createPersonAnchorNodes( |
|
|
|
|
personMap: Map<string, PersonConnection>, |
|
|
|
|
width: number, |
|
|
|
|
height: number, |
|
|
|
|
showSignedBy: boolean, |
|
|
|
|
showReferenced: boolean, |
|
|
|
|
limit: number = MAX_PERSON_NODES |
|
|
|
|
): { nodes: NetworkNode[], totalCount: number } { |
|
|
|
|
const anchorNodes: NetworkNode[] = []; |
|
|
|
|
|
|
|
|
|
const centerX = width / 2; |
|
|
|
|
const centerY = height / 2; |
|
|
|
|
|
|
|
|
|
// Calculate eligible persons and their connection counts
|
|
|
|
|
const eligiblePersons = Array.from(personMap.entries()) |
|
|
|
|
.map(([pubkey, connection]) => |
|
|
|
|
buildEligiblePerson(pubkey, connection, showSignedBy, showReferenced) |
|
|
|
|
) |
|
|
|
|
.filter((p): p is NonNullable<typeof p> => p !== null); |
|
|
|
|
|
|
|
|
|
// Sort by total connections (descending) and take only top N
|
|
|
|
|
eligiblePersons.sort((a, b) => b.totalConnections - a.totalConnections); |
|
|
|
|
|