|
1 | 1 | import { normalizePath, TFile } from "obsidian"; |
2 | 2 | import { uuidv7 } from "uuidv7"; |
3 | 3 | import type { DGSupabaseClient } from "@repo/database/lib/client"; |
| 4 | +import type { Json } from "@repo/database/dbTypes"; |
4 | 5 | import type DiscourseGraphPlugin from "~/index"; |
5 | 6 | import { ensureNodeInstanceId } from "~/utils/nodeInstanceId"; |
6 | 7 | import { getVaultId, getLocalSpaceUri } from "./supabaseContext"; |
@@ -614,20 +615,23 @@ const removeRelationLinkFromFrontmatter = async ( |
614 | 615 | f: TFile, |
615 | 616 | targetToRemove: TFile, |
616 | 617 | ): Promise<void> => { |
617 | | - await plugin.app.fileManager.processFrontMatter(f, (fm) => { |
618 | | - const raw = fm[relationTypeId] as unknown; |
619 | | - if (!raw) return; |
620 | | - const links = Array.isArray(raw) ? (raw as string[]) : [raw as string]; |
621 | | - const filtered = links.filter( |
622 | | - (link) => |
623 | | - !frontmatterLinkPointsToFile(plugin, link, f.path, targetToRemove), |
624 | | - ); |
625 | | - if (filtered.length === 0) { |
626 | | - delete fm[relationTypeId]; |
627 | | - } else { |
628 | | - fm[relationTypeId] = filtered.length === 1 ? filtered[0] : filtered; |
629 | | - } |
630 | | - }); |
| 618 | + await plugin.app.fileManager.processFrontMatter( |
| 619 | + f, |
| 620 | + (fm: Record<string, Json>) => { |
| 621 | + const raw = fm[relationTypeId] as unknown; |
| 622 | + if (!raw) return; |
| 623 | + const links = Array.isArray(raw) ? (raw as string[]) : [raw as string]; |
| 624 | + const filtered = links.filter( |
| 625 | + (link) => |
| 626 | + !frontmatterLinkPointsToFile(plugin, link, f.path, targetToRemove), |
| 627 | + ); |
| 628 | + if (filtered.length === 0) { |
| 629 | + delete fm[relationTypeId]; |
| 630 | + } else { |
| 631 | + fm[relationTypeId] = filtered.length === 1 ? filtered[0]! : filtered; |
| 632 | + } |
| 633 | + }, |
| 634 | + ); |
631 | 635 | }; |
632 | 636 |
|
633 | 637 | await removeFromFile(file, targetFile); |
|
0 commit comments