Skip to content

Commit 56fc9b8

Browse files
committed
improvement(files): cleanup pass — remove unnecessary useCallbacks, consolidate emcn icon imports
- Remove useCallback from 5 drag-event handlers in DataRow (passed to native <tr> elements, no observer) - Remove stable useCallback fns from 3 useMemo deps arrays in files.tsx (editingId/editValue remain) - Merge all @/components/emcn/icons subpath imports into barrel (files.tsx, action-bar, file-row-context-menu)
1 parent 6c52018 commit 56fc9b8

4 files changed

Lines changed: 22 additions & 48 deletions

File tree

apps/sim/app/workspace/[workspaceId]/components/resource/resource.tsx

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -534,40 +534,25 @@ const DataRow = memo(function DataRow({
534534
[selectable, row.id]
535535
)
536536

537-
const handleDragStart = useCallback(
538-
(e: DragEvent<HTMLTableRowElement>) => {
539-
rowDragDrop?.onDragStart?.(e, row.id)
540-
},
541-
[rowDragDrop, row.id]
542-
)
537+
const handleDragStart = (e: DragEvent<HTMLTableRowElement>) => {
538+
rowDragDrop?.onDragStart?.(e, row.id)
539+
}
543540

544-
const handleDragOver = useCallback(
545-
(e: DragEvent<HTMLTableRowElement>) => {
546-
rowDragDrop?.onDragOver?.(e, row.id)
547-
},
548-
[rowDragDrop, row.id]
549-
)
541+
const handleDragOver = (e: DragEvent<HTMLTableRowElement>) => {
542+
rowDragDrop?.onDragOver?.(e, row.id)
543+
}
550544

551-
const handleDragLeave = useCallback(
552-
(e: DragEvent<HTMLTableRowElement>) => {
553-
rowDragDrop?.onDragLeave?.(e, row.id)
554-
},
555-
[rowDragDrop, row.id]
556-
)
545+
const handleDragLeave = (e: DragEvent<HTMLTableRowElement>) => {
546+
rowDragDrop?.onDragLeave?.(e, row.id)
547+
}
557548

558-
const handleDrop = useCallback(
559-
(e: DragEvent<HTMLTableRowElement>) => {
560-
rowDragDrop?.onDrop?.(e, row.id)
561-
},
562-
[rowDragDrop, row.id]
563-
)
549+
const handleDrop = (e: DragEvent<HTMLTableRowElement>) => {
550+
rowDragDrop?.onDrop?.(e, row.id)
551+
}
564552

565-
const handleDragEnd = useCallback(
566-
(e: DragEvent<HTMLTableRowElement>) => {
567-
rowDragDrop?.onDragEnd?.(e, row.id)
568-
},
569-
[rowDragDrop, row.id]
570-
)
553+
const handleDragEnd = (e: DragEvent<HTMLTableRowElement>) => {
554+
rowDragDrop?.onDragEnd?.(e, row.id)
555+
}
571556

572557
return (
573558
<tr

apps/sim/app/workspace/[workspaceId]/files/components/action-bar/action-bar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import {
99
DropdownMenuItem,
1010
DropdownMenuSeparator,
1111
DropdownMenuTrigger,
12+
Folder,
1213
Tooltip,
1314
Trash2,
1415
} from '@/components/emcn'
15-
import { Folder } from '@/components/emcn/icons'
1616
import { cn } from '@/lib/core/utils/cn'
1717
import type { MoveOptionNode } from '@/app/workspace/[workspaceId]/files/move-options'
1818
import { renderMoveOption } from '@/app/workspace/[workspaceId]/files/move-options'

apps/sim/app/workspace/[workspaceId]/files/components/file-row-context-menu/file-row-context-menu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import {
1212
DropdownMenuSubTrigger,
1313
DropdownMenuTrigger,
1414
Eye,
15+
Folder,
16+
FolderInput,
1517
Pencil,
1618
Trash2,
1719
} from '@/components/emcn'
18-
import { Folder, FolderInput } from '@/components/emcn/icons'
1920
import type { MoveOptionNode } from '@/app/workspace/[workspaceId]/files/move-options'
2021
import { renderMoveOption } from '@/app/workspace/[workspaceId]/files/move-options'
2122

apps/sim/app/workspace/[workspaceId]/files/files.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import {
1111
type ComboboxOption,
1212
Download,
1313
Eye,
14+
File as FilesIcon,
15+
Folder,
16+
FolderPlus,
1417
Loader,
1518
Modal,
1619
ModalBody,
@@ -23,7 +26,6 @@ import {
2326
toast,
2427
Upload,
2528
} from '@/components/emcn'
26-
import { File as FilesIcon, Folder, FolderPlus } from '@/components/emcn/icons'
2729
import { getDocumentIcon } from '@/components/icons/document-icons'
2830
import { triggerFileDownload } from '@/lib/uploads/client/download'
2931
import type { WorkspaceFileRecord } from '@/lib/uploads/contexts/workspace'
@@ -474,15 +476,7 @@ export function Files() {
474476
},
475477
}
476478
})
477-
}, [
478-
baseRows,
479-
listRename.editingId,
480-
listRename.editValue,
481-
listRename.setEditValue,
482-
listRename.submitRename,
483-
listRename.cancelRename,
484-
filteredFiles,
485-
])
479+
}, [baseRows, listRename.editingId, listRename.editValue, filteredFiles])
486480

487481
const visibleRowIds = useMemo(() => rows.map((row) => row.id), [rows])
488482

@@ -1015,9 +1009,6 @@ export function Files() {
10151009
handleBackAttempt,
10161010
headerRename.editingId,
10171011
headerRename.editValue,
1018-
headerRename.setEditValue,
1019-
headerRename.submitRename,
1020-
headerRename.cancelRename,
10211012
handleStartHeaderRename,
10221013
handleDownloadSelected,
10231014
handleDeleteSelected,
@@ -1541,9 +1532,6 @@ export function Files() {
15411532
canEdit,
15421533
breadcrumbRename.editingId,
15431534
breadcrumbRename.editValue,
1544-
breadcrumbRename.setEditValue,
1545-
breadcrumbRename.submitRename,
1546-
breadcrumbRename.cancelRename,
15471535
])
15481536

15491537
const memberOptions: ComboboxOption[] = useMemo(

0 commit comments

Comments
 (0)