diff --git a/web/src/components/file-filters.tsx b/web/src/components/file-filters.tsx index 416cc3f..22d840b 100644 --- a/web/src/components/file-filters.tsx +++ b/web/src/components/file-filters.tsx @@ -10,11 +10,9 @@ import { import TableColumnFilter, { type Column, } from "@/components/table-column-filter"; -import { - type RowHeight, - TableRowHeightSwitch, -} from "@/components/table-row-height-switch"; +import { type RowHeight } from "@/components/table-row-height-switch"; import FileTypeFilter from "@/components/file-type-filter"; +import dynamic from "next/dynamic"; interface FileFiltersProps { telegramId: string; @@ -27,6 +25,14 @@ interface FileFiltersProps { setRowHeight: (e: RowHeight) => void; } +const TableRowHeightSwitch = dynamic( + () => + import("@/components/table-row-height-switch").then( + (mod) => mod.TableRowHeightSwitch, + ), + { ssr: false }, +); + export function FileFilters({ telegramId, chatId, @@ -39,7 +45,7 @@ export function FileFilters({ }: FileFiltersProps) { return (
-
+
- {!!rowHeight && !!setRowHeight && ( - - )} +
); diff --git a/web/src/components/file-list.tsx b/web/src/components/file-list.tsx index b5a1231..55b3c33 100644 --- a/web/src/components/file-list.tsx +++ b/web/src/components/file-list.tsx @@ -4,8 +4,8 @@ import { FileCard } from "./file-card"; import React, { memo, type ReactNode, + useCallback, useEffect, - useMemo, useRef, useState, } from "react"; @@ -155,25 +155,23 @@ export function FileList({ accountId, chatId }: FileListProps) { return () => observer.disconnect(); }, [handleLoadMore]); - const contentWH = useMemo(() => { + const dynamicClass = useCallback(() => { switch (rowHeight) { case "s": - return "h-6 w-6"; + return { + content: "h-6 w-6", + contentCell: "w-6", + }; case "m": - return "h-20 w-20"; + return { + content: "h-20 w-20", + contentCell: "w-24", + }; case "l": - return "h-60 w-60"; - } - }, [rowHeight]); - - const contentCellWidth = useMemo(() => { - switch (rowHeight) { - case "s": - return "w-6"; - case "m": - return "w-24"; - case "l": - return "w-64"; + return { + content: "h-60 w-60", + contentCell: "w-64", + }; } }, [rowHeight]); @@ -245,7 +243,7 @@ export function FileList({ accountId, chatId }: FileListProps) { return (
@@ -269,7 +267,7 @@ export function FileList({ accountId, chatId }: FileListProps) { @@ -371,9 +369,10 @@ export function FileList({ accountId, chatId }: FileListProps) { col.isVisible ? ( {col.label} @@ -406,7 +405,9 @@ export function FileList({ accountId, chatId }: FileListProps) { key={col.id} className={cn( col.className ?? "", - col.id === "content" ? contentCellWidth : "", + col.id === "content" + ? dynamicClass().contentCell + : "", )} > {columnRenders[col.id]!(file, index)}