mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 18:05:55 +01:00 
			
		
		
		
	refactor(react/dialogs): solve client errors
This commit is contained in:
		| @@ -39,7 +39,7 @@ export interface Suggestion { | ||||
| } | ||||
|  | ||||
| export interface Options { | ||||
|     container?: HTMLElement; | ||||
|     container?: HTMLElement | null; | ||||
|     fastSearch?: boolean; | ||||
|     allowCreatingNotes?: boolean; | ||||
|     allowJumpToSearchNotes?: boolean; | ||||
|   | ||||
| @@ -21,7 +21,7 @@ interface ExportDialogProps { | ||||
|  | ||||
| function ExportDialogComponent() { | ||||
|     const [ opts, setOpts ] = useState<ExportDialogProps>(); | ||||
|     const [ exportType, setExportType ] = useState(opts?.defaultType ?? "subtree"); | ||||
|     const [ exportType, setExportType ] = useState<string>(opts?.defaultType ?? "subtree"); | ||||
|     const [ subtreeFormat, setSubtreeFormat ] = useState("html"); | ||||
|     const [ singleFormat, setSingleFormat ] = useState("html"); | ||||
|     const [ opmlVersion, setOpmlVersion ] = useState("2.0"); | ||||
|   | ||||
| @@ -52,7 +52,11 @@ function JumpToNoteDialogComponent() { | ||||
|         setIsCommandMode(text.startsWith(">")); | ||||
|     }, [ text ]); | ||||
|  | ||||
|     async function onItemSelected(suggestion: Suggestion) { | ||||
|     async function onItemSelected(suggestion?: Suggestion | null) { | ||||
|         if (!suggestion) { | ||||
|             return; | ||||
|         } | ||||
|          | ||||
|         setShown(false); | ||||
|         if (suggestion.notePath) { | ||||
|             appContext.tabManager.getActiveContext()?.setNote(suggestion.notePath); | ||||
|   | ||||
| @@ -8,7 +8,7 @@ import Button from "../react/Button"; | ||||
| import Modal from "../react/Modal"; | ||||
| import ReactBasicWidget from "../react/ReactBasicWidget"; | ||||
| import hoisted_note from "../../services/hoisted_note"; | ||||
| import type { RecentChangesRow } from "@triliumnext/commons"; | ||||
| import type { RecentChangeRow } from "@triliumnext/commons"; | ||||
| import froca from "../../services/froca"; | ||||
| import { formatDateTime } from "../../utils/formatters"; | ||||
| import link from "../../services/link"; | ||||
| @@ -18,7 +18,7 @@ import useTriliumEvent from "../react/hooks"; | ||||
|  | ||||
| function RecentChangesDialogComponent() { | ||||
|     const [ ancestorNoteId, setAncestorNoteId ] = useState<string>(); | ||||
|     const [ groupedByDate, setGroupedByDate ] = useState<Map<String, RecentChangesRow[]>>(); | ||||
|     const [ groupedByDate, setGroupedByDate ] = useState<Map<String, RecentChangeRow[]>>(); | ||||
|     const [ needsRefresh, setNeedsRefresh ] = useState(false); | ||||
|     const [ shown, setShown ] = useState(false); | ||||
|  | ||||
| @@ -34,7 +34,7 @@ function RecentChangesDialogComponent() { | ||||
|                 setNeedsRefresh(false);    | ||||
|             } | ||||
|  | ||||
|             server.get<RecentChangesRow[]>(`recent-changes/${ancestorNoteId}`) | ||||
|             server.get<RecentChangeRow[]>(`recent-changes/${ancestorNoteId}`) | ||||
|                 .then(async (recentChanges) => { | ||||
|                     // preload all notes into cache | ||||
|                     await froca.getNotes( | ||||
| @@ -78,7 +78,7 @@ function RecentChangesDialogComponent() { | ||||
|     ) | ||||
| } | ||||
|  | ||||
| function RecentChangesTimeline({ groupedByDate, setShown }: { groupedByDate: Map<String, RecentChangesRow[]>, setShown: Dispatch<StateUpdater<boolean>> }) { | ||||
| function RecentChangesTimeline({ groupedByDate, setShown }: { groupedByDate: Map<String, RecentChangeRow[]>, setShown: Dispatch<StateUpdater<boolean>> }) { | ||||
|     return ( | ||||
|         <> | ||||
|             { Array.from(groupedByDate.entries()).map(([dateDay, dayChanges]) => { | ||||
| @@ -129,7 +129,7 @@ function NoteLink({ notePath, title }: { notePath: string, title: string }) { | ||||
|     ); | ||||
| } | ||||
|  | ||||
| function DeletedNoteLink({ change, setShown }: { change: RecentChangesRow, setShown: Dispatch<StateUpdater<boolean>> }) { | ||||
| function DeletedNoteLink({ change, setShown }: { change: RecentChangeRow, setShown: Dispatch<StateUpdater<boolean>> }) { | ||||
|     return ( | ||||
|         <> | ||||
|             <span className="note-title">{change.current_title}</span> | ||||
| @@ -165,8 +165,8 @@ export default class RecentChangesDialog extends ReactBasicWidget { | ||||
|  | ||||
| } | ||||
|  | ||||
| function groupByDate(rows: RecentChangesRow[]) { | ||||
|     const groupedByDate = new Map<String, RecentChangesRow[]>(); | ||||
| function groupByDate(rows: RecentChangeRow[]) { | ||||
|     const groupedByDate = new Map<String, RecentChangeRow[]>(); | ||||
|  | ||||
|     for (const row of rows) { | ||||
|         const dateDay = row.date.substr(0, 10); | ||||
|   | ||||
| @@ -9,8 +9,8 @@ interface DropdownProps { | ||||
| } | ||||
|  | ||||
| export default function Dropdown({ className, isStatic, children }: DropdownProps) { | ||||
|     const dropdownRef = useRef<HTMLDivElement>(); | ||||
|     const triggerRef = useRef<HTMLButtonElement>(); | ||||
|     const dropdownRef = useRef<HTMLDivElement | null>(null); | ||||
|     const triggerRef = useRef<HTMLButtonElement | null>(null); | ||||
|  | ||||
|     if (triggerRef?.current) { | ||||
|         useEffect(() => { | ||||
|   | ||||
| @@ -9,7 +9,7 @@ interface NoteAutocompleteProps { | ||||
|     inputRef?: RefObject<HTMLInputElement>; | ||||
|     text?: string; | ||||
|     placeholder?: string; | ||||
|     container?: RefObject<HTMLDivElement>; | ||||
|     container?: RefObject<HTMLElement | null | undefined>; | ||||
|     containerStyle?: CSSProperties; | ||||
|     opts?: Omit<Options, "container">; | ||||
|     onChange?: (suggestion: Suggestion | null) => void; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user