Commit 9f34a27
committed
refactor(files): cleanup anti-patterns across file viewer components
Six-pass cleanup over the file-viewer directory:
Effects (you-might-not-need-an-effect):
- AudioPreview, VideoPreview: replace reset useEffect with key={file.id} so
the component remounts on file change — React's canonical solution
- DocxPreview: same key-prop fix; removes a 5-setState reset effect that was
also clearing containerRef.current.innerHTML unnecessarily
Callbacks (you-might-not-need-a-callback):
- handleEditorMount, handleEditorChange: remove useCallback — MonacoEditor is
dynamic(), not React.memo, so reference stability has no observer
- markSavedContent: remove useCallback — called only through an onSaveRef,
never directly observed
- DataTable.setInputRef: remove useCallback — callback refs on native elements
are called regardless of reference identity
Design tokens (emcn-design-review):
- VideoPreview: bg-black → bg-[var(--surface-inverted)]
- HtmlPreview iframe: bg-white → bg-[var(--surface-2)]
useMemo, useState, and react-query passes found no issues.1 parent a05542a commit 9f34a27
3 files changed
Lines changed: 22 additions & 43 deletions
File tree
- apps/sim/app/workspace/[workspaceId]/files/components/file-viewer
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
Lines changed: 18 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
524 | | - | |
| 524 | + | |
525 | 525 | | |
526 | | - | |
| 526 | + | |
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
| |||
596 | 596 | | |
597 | 597 | | |
598 | 598 | | |
599 | | - | |
| 599 | + | |
600 | 600 | | |
601 | 601 | | |
602 | 602 | | |
603 | | - | |
| 603 | + | |
604 | 604 | | |
605 | 605 | | |
606 | 606 | | |
607 | | - | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
608 | 615 | | |
609 | 616 | | |
610 | 617 | | |
| |||
704 | 711 | | |
705 | 712 | | |
706 | 713 | | |
707 | | - | |
708 | 714 | | |
709 | 715 | | |
710 | 716 | | |
| |||
713 | 719 | | |
714 | 720 | | |
715 | 721 | | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | 722 | | |
720 | 723 | | |
721 | 724 | | |
| |||
825 | 828 | | |
826 | 829 | | |
827 | 830 | | |
828 | | - | |
829 | 831 | | |
830 | 832 | | |
831 | 833 | | |
| |||
836 | 838 | | |
837 | 839 | | |
838 | 840 | | |
839 | | - | |
| 841 | + | |
840 | 842 | | |
841 | 843 | | |
842 | 844 | | |
| |||
854 | 856 | | |
855 | 857 | | |
856 | 858 | | |
857 | | - | |
| 859 | + | |
858 | 860 | | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
865 | 864 | | |
866 | 865 | | |
867 | 866 | | |
| |||
1221 | 1220 | | |
1222 | 1221 | | |
1223 | 1222 | | |
1224 | | - | |
1225 | | - | |
1226 | | - | |
1227 | | - | |
1228 | 1223 | | |
1229 | 1224 | | |
1230 | 1225 | | |
| |||
1290 | 1285 | | |
1291 | 1286 | | |
1292 | 1287 | | |
1293 | | - | |
1294 | | - | |
1295 | | - | |
1296 | | - | |
1297 | 1288 | | |
1298 | 1289 | | |
1299 | 1290 | | |
| |||
1320 | 1311 | | |
1321 | 1312 | | |
1322 | 1313 | | |
1323 | | - | |
| 1314 | + | |
1324 | 1315 | | |
1325 | 1316 | | |
1326 | 1317 | | |
| |||
1440 | 1431 | | |
1441 | 1432 | | |
1442 | 1433 | | |
1443 | | - | |
1444 | | - | |
1445 | | - | |
1446 | | - | |
1447 | | - | |
1448 | | - | |
1449 | | - | |
1450 | | - | |
1451 | | - | |
1452 | | - | |
1453 | 1434 | | |
1454 | 1435 | | |
1455 | 1436 | | |
| |||
2019 | 2000 | | |
2020 | 2001 | | |
2021 | 2002 | | |
2022 | | - | |
2023 | 2003 | | |
2024 | 2004 | | |
2025 | 2005 | | |
| |||
2033 | 2013 | | |
2034 | 2014 | | |
2035 | 2015 | | |
2036 | | - | |
2037 | 2016 | | |
2038 | 2017 | | |
2039 | 2018 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
851 | 851 | | |
852 | 852 | | |
853 | 853 | | |
854 | | - | |
| 854 | + | |
855 | 855 | | |
856 | 856 | | |
857 | 857 | | |
| |||
0 commit comments