fix: code review cleanup - schema sync, type safety, null handling
- Sync KnowledgeLink schema with migration (add displayText, positionStart, positionEnd, resolved) - Make targetId optional to support unresolved links - Fix null handling in graph.service.ts (skip unresolved links) - Add explicit types to frontend components (remove implicit any) - Remove unused WikiLink import - Add null-safe statusInfo check in EntryCard
This commit is contained in:
@@ -104,8 +104,11 @@ export class GraphService {
|
||||
|
||||
// Continue BFS if not at max depth
|
||||
if (depth < maxDepth) {
|
||||
// Process outgoing links
|
||||
// Process outgoing links (only resolved ones)
|
||||
for (const link of currentEntry.outgoingLinks) {
|
||||
// Skip unresolved links
|
||||
if (!link.targetId || !link.resolved) continue;
|
||||
|
||||
// Add edge
|
||||
edges.push({
|
||||
id: link.id,
|
||||
@@ -122,8 +125,11 @@ export class GraphService {
|
||||
}
|
||||
}
|
||||
|
||||
// Process incoming links
|
||||
// Process incoming links (only resolved ones)
|
||||
for (const link of currentEntry.incomingLinks) {
|
||||
// Skip unresolved links
|
||||
if (!link.targetId || !link.resolved) continue;
|
||||
|
||||
// Add edge
|
||||
const edgeExists = edges.some(
|
||||
(e) => e.sourceId === link.sourceId && e.targetId === link.targetId
|
||||
|
||||
@@ -131,7 +131,9 @@ export class LinkResolutionService {
|
||||
return null;
|
||||
}
|
||||
|
||||
return fuzzyMatches[0].id;
|
||||
// Return the single match
|
||||
const match = fuzzyMatches[0];
|
||||
return match ? match.id : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { PrismaService } from "../../prisma/prisma.service";
|
||||
import { LinkResolutionService } from "./link-resolution.service";
|
||||
import { parseWikiLinks, WikiLink } from "../utils/wiki-link-parser";
|
||||
import { parseWikiLinks } from "../utils/wiki-link-parser";
|
||||
|
||||
/**
|
||||
* Represents a backlink to a knowledge entry
|
||||
|
||||
Reference in New Issue
Block a user