Skip to content

Build your personal knowledge base with Trilium Notes

chore(react/collections): fix the rest of client type errors

Elian Doran6077da0df8a7
diff --git a/apps/client/src/widgets/collections/NoteList.tsx b/apps/client/src/widgets/collections/NoteList.tsx
index f16db0b722..98d9a3febf 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 6b8bc0a428..57c90b59ad 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<T> extends Omit<Options, "data" | "footerElement" | "index"> {
tabulatorRef: RefObject<VanillaTabulator>;
@@ -12,7 +13,7 @@ interface TableProps<T> extends Omit<Options, "data" | "footerElement" | "index"
modules?: (new (table: VanillaTabulator) => Module)[];
events?: Partial<EventCallBackMethods>;
index: keyof T;
- footerElement?: JSX.Element;
+ footerElement?: string | HTMLElement | JSX.Element;
}
export default function Tabulator<T>({ className, columns, data, modules, tabulatorRef: externalTabulatorRef, footerElement, events, index, ...restProps }: TableProps<T>) {
@@ -33,7 +34,7 @@ export default function Tabulator<T>({ 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 215b44f1a0..e0f40fd879 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,