From 6077da0df8a7cf725fa122ff48dc0cafbcd5cb01 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 14 Sep 2025 10:53:54 +0300 Subject: [PATCH] chore(react/collections): fix the rest of client type errors --- apps/client/src/widgets/collections/NoteList.tsx | 4 ++-- .../src/widgets/collections/table/tabulator.tsx | 7 ++++--- apps/client/src/widgets/react/TouchBar.tsx | 15 ++++----------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/apps/client/src/widgets/collections/NoteList.tsx b/apps/client/src/widgets/collections/NoteList.tsx index f16db0b72..98d9a3feb 100644 --- a/apps/client/src/widgets/collections/NoteList.tsx +++ b/apps/client/src/widgets/collections/NoteList.tsx @@ -3,9 +3,9 @@ import { useNoteContext, useNoteLabel, useNoteLabelBoolean, useTriliumEvent } fr import FNote from "../../entities/fnote"; import "./NoteList.css"; import { ListView, GridView } from "./legacy/ListOrGridView"; -import { useEffect, useMemo, useRef, useState } from "preact/hooks"; +import { useEffect, useRef, useState } from "preact/hooks"; import GeoView from "./geomap"; -import ViewModeStorage from "../view_widgets/view_mode_storage"; +import ViewModeStorage from "./view_mode_storage"; import CalendarView from "./calendar"; import TableView from "./table"; import BoardView from "./board"; diff --git a/apps/client/src/widgets/collections/table/tabulator.tsx b/apps/client/src/widgets/collections/table/tabulator.tsx index 6b8bc0a42..57c90b59a 100644 --- a/apps/client/src/widgets/collections/table/tabulator.tsx +++ b/apps/client/src/widgets/collections/table/tabulator.tsx @@ -2,8 +2,9 @@ import { useContext, useEffect, useLayoutEffect, useRef } from "preact/hooks"; import { EventCallBackMethods, Module, Options, Tabulator as VanillaTabulator } from "tabulator-tables"; import "tabulator-tables/dist/css/tabulator.css"; import "../../../../src/stylesheets/table.css"; -import { JSX, RefObject, VNode } from "preact"; import { ParentComponent, renderReactWidget } from "../../react/react_utils"; +import { JSX } from "preact/jsx-runtime"; +import { isValidElement, RefObject } from "preact"; interface TableProps extends Omit { tabulatorRef: RefObject; @@ -12,7 +13,7 @@ interface TableProps extends Omit Module)[]; events?: Partial; index: keyof T; - footerElement?: JSX.Element; + footerElement?: string | HTMLElement | JSX.Element; } export default function Tabulator({ className, columns, data, modules, tabulatorRef: externalTabulatorRef, footerElement, events, index, ...restProps }: TableProps) { @@ -33,7 +34,7 @@ export default function Tabulator({ className, columns, data, modules, tabula const tabulator = new VanillaTabulator(containerRef.current, { columns, data, - footerElement: (parentComponent && footerElement ? renderReactWidget(parentComponent, footerElement)[0] : undefined), + footerElement: (parentComponent && isValidElement(footerElement) ? renderReactWidget(parentComponent, footerElement)[0] : undefined), index: index as string | number | undefined, ...restProps }); diff --git a/apps/client/src/widgets/react/TouchBar.tsx b/apps/client/src/widgets/react/TouchBar.tsx index 215b44f1a..e0f40fd87 100644 --- a/apps/client/src/widgets/react/TouchBar.tsx +++ b/apps/client/src/widgets/react/TouchBar.tsx @@ -148,19 +148,12 @@ export function TouchBarButton({ label, icon, click, enabled }: ButtonProps) { export function TouchBarSegmentedControl({ mode, segments, selectedIndex, onChange }: SegmentedControlProps) { const api = useContext(TouchBarContext); - const processedSegments = segments.map((segment) => { - if (segment.icon) { - if (!api) return undefined; - return { - ...segment, - icon: buildIcon(api?.nativeImage, segment.icon) - } - } else { - return segment; - } - }); if (api) { + const processedSegments: Electron.SegmentedControlSegment[] = segments.map(({icon, ...restProps}) => ({ + ...restProps, + icon: icon ? buildIcon(api.nativeImage, icon) : undefined + })); const item = new api.TouchBar.TouchBarSegmentedControl({ mode, selectedIndex, segments: processedSegments,