Skip to content

Build your personal knowledge base with Trilium Notes

chore(client): fix typecheck

Elian Doranfef30f4bea84
diff --git a/apps/client/src/types-pdfjs.d.ts b/apps/client/src/types-pdfjs.d.ts
new file mode 100644
index 0000000000..54a440f162
--- /dev/null
+++ b/apps/client/src/types-pdfjs.d.ts
@@ -0,0 +1,3 @@
+interface Window {
+ TRILIUM_VIEW_HISTORY_STORE?: object;
+}
diff --git a/apps/client/src/widgets/collections/NoteList.tsx b/apps/client/src/widgets/collections/NoteList.tsx
index 5626cc33cf..ec80e6b197 100644
--- a/apps/client/src/widgets/collections/NoteList.tsx
+++ b/apps/client/src/widgets/collections/NoteList.tsx
@@ -11,7 +11,8 @@ import froca from "../../services/froca";
import { subscribeToMessages, unsubscribeToMessage as unsubscribeFromMessage } from "../../services/ws";
import { useNoteContext, useNoteLabel, useNoteLabelBoolean, useNoteProperty, useTriliumEvent } from "../react/hooks";
import { allViewTypes, ViewModeMedia, ViewModeProps, ViewTypeOptions } from "./interface";
-import ViewModeStorage from "./view_mode_storage";
+import ViewModeStorage, { type ViewModeStorageType } from "./view_mode_storage";
+
interface NoteListProps {
note: FNote | null | undefined;
notePath: string | null | undefined;
@@ -215,7 +216,7 @@ export function useNoteIds(note: FNote | null | undefined, viewType: ViewTypeOpt
return noteIds;
}
-export function useViewModeConfig<T extends object>(note: FNote | null | undefined, viewType: ViewTypeOptions | undefined) {
+export function useViewModeConfig<T extends object>(note: FNote | null | undefined, viewType: ViewModeStorageType | undefined) {
const [ viewConfig, setViewConfig ] = useState<{
config: T | undefined;
storeFn: (data: T) => void;
diff --git a/apps/client/src/widgets/collections/view_mode_storage.ts b/apps/client/src/widgets/collections/view_mode_storage.ts
index 95c3ff8004..b8c3b94f25 100644
--- a/apps/client/src/widgets/collections/view_mode_storage.ts
+++ b/apps/client/src/widgets/collections/view_mode_storage.ts
@@ -4,14 +4,16 @@ import { ViewTypeOptions } from "../collections/interface";
const ATTACHMENT_ROLE = "viewConfig";
+export type ViewModeStorageType = ViewTypeOptions | "pdfHistory";
+
export default class ViewModeStorage<T extends object> {
private note: FNote;
private attachmentName: string;
- constructor(note: FNote, viewType: ViewTypeOptions) {
+ constructor(note: FNote, viewType: ViewModeStorageType) {
this.note = note;
- this.attachmentName = viewType + ".json";
+ this.attachmentName = `${viewType}.json`;
}
async store(data: T) {