fix: correct networking imports and API response format

- Fix useSession → useAuth import (matches actual export)
- Fix GraphEdge properties: source/target instead of fromUserId/toUserId
- Add missing trustLevel, effectiveTrustLevel to edge response
- Add myConnections to NetworkGraph type
- Prefix unused myConnections param with underscore

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2025-12-05 22:51:58 -08:00
parent e30dd4d1ec
commit 6775dcca93
7 changed files with 17 additions and 12 deletions

View File

@ -154,7 +154,7 @@ const styles = {
export function NetworkGraphMinimap({
nodes,
edges,
myConnections,
myConnections: _myConnections,
currentUserId,
onConnect,
onDisconnect,

View File

@ -9,7 +9,7 @@ import React, { useState, useCallback, useMemo } from 'react';
import { useEditor, useValue } from 'tldraw';
import { NetworkGraphMinimap } from './NetworkGraphMinimap';
import { useNetworkGraph } from './useNetworkGraph';
import { useSession } from '../../context/AuthContext';
import { useAuth } from '../../context/AuthContext';
import type { GraphEdge, TrustLevel } from '../../lib/networking';
// =============================================================================
@ -26,7 +26,7 @@ interface NetworkGraphPanelProps {
export function NetworkGraphPanel({ onExpand }: NetworkGraphPanelProps) {
const editor = useEditor();
const { session } = useSession();
const { session } = useAuth();
const [isCollapsed, setIsCollapsed] = useState(false);
const [selectedEdge, setSelectedEdge] = useState<GraphEdge | null>(null);

View File

@ -9,7 +9,7 @@
*/
import { useState, useEffect, useCallback, useMemo } from 'react';
import { useSession } from '../../context/AuthContext';
import { useAuth } from '../../context/AuthContext';
import {
getMyNetworkGraph,
getRoomNetworkGraph,
@ -80,7 +80,7 @@ export function useNetworkGraph(options: UseNetworkGraphOptions = {}): UseNetwor
useCache = true,
} = options;
const { session } = useSession();
const { session } = useAuth();
const [state, setState] = useState<NetworkGraphState>({
nodes: [],
edges: [],

View File

@ -40,8 +40,8 @@ async function fetchJson<T>(url: string, options?: RequestInit): Promise<T> {
});
if (!response.ok) {
const error = await response.json().catch(() => ({ message: response.statusText }));
throw new Error(error.message || `HTTP ${response.status}`);
const errorData = await response.json().catch(() => ({ message: response.statusText })) as { message?: string };
throw new Error(errorData.message || `HTTP ${response.status}`);
}
return response.json();
@ -278,6 +278,8 @@ export function buildGraphEdge(
id: connection.id,
source: connection.fromUserId,
target: connection.toUserId,
trustLevel: connection.trustLevel,
effectiveTrustLevel: connection.effectiveTrustLevel,
isMutual: connection.isMutual,
metadata: isOnEdge ? connection.metadata : undefined,
isVisible: true,

View File

@ -144,6 +144,7 @@ export interface GraphEdge {
export interface NetworkGraph {
nodes: GraphNode[];
edges: GraphEdge[];
myConnections: string[]; // User IDs the current user is connected to
}
/**

View File

@ -185,7 +185,7 @@ export async function updateMyProfile(request: IRequest, env: Environment): Prom
`).bind(userId, body.displayName || null, body.bio || null, body.avatarColor || null).run();
// Return updated profile
return getUserProfile({ ...request, params: { userId } } as IRequest, env);
return getUserProfile({ ...request, params: { userId } } as unknown as IRequest, env);
} catch (error) {
console.error('Update profile error:', error);
return errorResponse('Failed to update profile', 500);
@ -712,10 +712,12 @@ export async function getNetworkGraph(request: IRequest, env: Environment): Prom
const graphEdges: GraphEdge[] = (edges.results || []).map((e: any) => ({
id: e.id,
fromUserId: e.fromUserId,
toUserId: e.toUserId,
createdAt: e.createdAt,
source: e.fromUserId,
target: e.toUserId,
trustLevel: e.trustLevel || 'connected',
effectiveTrustLevel: e.isMutual ? (e.trustLevel || 'connected') : null,
isMutual: !!e.isMutual,
isVisible: true,
metadata: (e.fromUserId === userId || e.toUserId === userId) && (e.label || e.notes || e.color || e.strength) ? {
label: e.label,
notes: e.notes,

View File

@ -832,7 +832,7 @@ const router = AutoRouter<IRequest, [env: Environment, ctx: ExecutionContext]>({
// User search and profiles
.get("/api/networking/users/search", searchUsers)
.get("/api/networking/users/me", (req, env) => getUserProfile({ ...req, params: { userId: req.headers.get('X-User-Id') || '' } } as IRequest, env))
.get("/api/networking/users/me", (req, env) => getUserProfile({ ...req, params: { userId: req.headers.get('X-User-Id') || '' } } as unknown as IRequest, env))
.put("/api/networking/users/me", updateMyProfile)
.get("/api/networking/users/:userId", getUserProfile)