Skip to content

Commit bb47db8

Browse files
committed
check type adjustments
1 parent bdc1b69 commit bb47db8

4 files changed

Lines changed: 35 additions & 22 deletions

File tree

apps/obsidian/src/components/SearchBar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ class GenericSuggest<T> extends AbstractInputSuggest<T> {
99
private asyncSearchFn: (query: string) => Promise<T[]>;
1010
private minQueryLength: number;
1111
private debounceTimeout: number | null = null;
12+
textInputEl: HTMLInputElement;
1213

1314
constructor(
1415
app: App,
15-
private textInputEl: HTMLInputElement,
16+
textInputEl: HTMLInputElement,
1617
onSelectCallback: (item: T) => void,
1718
config: {
1819
getItemText: (item: T) => string;
@@ -27,6 +28,7 @@ class GenericSuggest<T> extends AbstractInputSuggest<T> {
2728
this.renderItemFn = config.renderItem || this.defaultRenderItem.bind(this);
2829
this.asyncSearchFn = config.asyncSearch;
2930
this.minQueryLength = config.minQueryLength || 0;
31+
this.textInputEl = textInputEl;
3032
}
3133

3234
async getSuggestions(inputStr: string): Promise<T[]> {

apps/obsidian/src/components/SuggestInput.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import React, { useRef, useEffect, useState, useCallback } from "react";
22
import { AbstractInputSuggest, App } from "obsidian";
33
import { usePlugin } from "./PluginContext";
4+
import { te } from "date-fns/locale/te";
45

56
class GenericSuggestInput<T> extends AbstractInputSuggest<T> {
67
private getSuggestionsFn: (query: string) => T[];
78
private onSelectCallback: (item: T) => void;
89
private getDisplayTextFn: (item: T) => string;
910
private renderItemFn?: (item: T, el: HTMLElement) => void;
11+
textInputEl: HTMLInputElement;
1012

1113
constructor(
1214
app: App,
13-
private textInputEl: HTMLInputElement,
15+
textInputEl: HTMLInputElement,
1416
config: {
1517
getSuggestions: (query: string) => T[];
1618
onSelect: (item: T) => void;
@@ -23,6 +25,7 @@ class GenericSuggestInput<T> extends AbstractInputSuggest<T> {
2325
this.onSelectCallback = config.onSelect;
2426
this.getDisplayTextFn = config.getDisplayText;
2527
this.renderItemFn = config.renderItem;
28+
this.textInputEl = textInputEl;
2629
}
2730

2831
getSuggestions(inputStr: string): T[] {

apps/obsidian/src/utils/relationsStore.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { normalizePath, TFile } from "obsidian";
22
import { uuidv7 } from "uuidv7";
33
import type { DGSupabaseClient } from "@repo/database/lib/client";
4+
import type { Json } from "@repo/database/dbTypes";
45
import type DiscourseGraphPlugin from "~/index";
56
import { ensureNodeInstanceId } from "~/utils/nodeInstanceId";
67
import { getVaultId, getLocalSpaceUri } from "./supabaseContext";
@@ -614,20 +615,23 @@ const removeRelationLinkFromFrontmatter = async (
614615
f: TFile,
615616
targetToRemove: TFile,
616617
): 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+
);
631635
};
632636

633637
await removeFromFile(file, targetFile);

apps/obsidian/src/utils/templates.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ import {
66
getFrontMatterInfo,
77
} from "obsidian";
88
import type { Settings } from "~/types";
9+
import type { Json } from "@repo/database/dbTypes";
910

1011
type TemplatePluginInfo = {
1112
isEnabled: boolean;
1213
folderPath: string;
1314
};
1415

1516
const mergeFrontmatter = (
16-
template: Record<string, any>,
17-
current: Record<string, any>,
18-
): Record<string, any> => {
17+
template: Record<string, Json | undefined>,
18+
current: Record<string, Json | undefined>,
19+
): Record<string, Json | undefined> => {
1920
const result = { ...template };
2021

2122
for (const [key, currentValue] of Object.entries(current)) {
@@ -344,9 +345,12 @@ export const applyTemplate = async ({
344345
currentFrontmatter,
345346
);
346347

347-
await app.fileManager.processFrontMatter(targetFile, (fm) => {
348-
Object.assign(fm, mergedFrontmatter);
349-
});
348+
await app.fileManager.processFrontMatter(
349+
targetFile,
350+
(fm: Record<string, Json | undefined>) => {
351+
Object.assign(fm, mergedFrontmatter);
352+
},
353+
);
350354

351355
const frontmatterInfo = getFrontMatterInfo(templateContent);
352356
const templateBody = frontmatterInfo.exists

0 commit comments

Comments
 (0)