Skip to content

Commit 79555d9

Browse files
committed
some quick fixes
1 parent 10398c1 commit 79555d9

3 files changed

Lines changed: 33 additions & 34 deletions

File tree

src/views/RefreshDataDialog.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,16 @@ import {
1616
Tab,
1717
LinearProgress,
1818
Input,
19-
Alert,
20-
Tooltip,
2119
Link,
2220
alpha,
2321
useTheme,
2422
} from '@mui/material';
2523
import CloseIcon from '@mui/icons-material/Close';
2624
import UploadFileIcon from '@mui/icons-material/UploadFile';
27-
import { useDispatch, useSelector } from 'react-redux';
28-
import { AppDispatch } from '../app/store';
29-
import { DataFormulatorState, dfActions, dfSelectors, fetchFieldSemanticType } from '../app/dfSlice';
25+
import { useSelector } from 'react-redux';
26+
import { DataFormulatorState } from '../app/dfSlice';
3027
import { DictTable } from '../components/ComponentType';
31-
import { createTableFromFromObjectArray, createTableFromText, loadTextDataWrapper, loadBinaryDataWrapper } from '../data/utils';
32-
import { getUrls } from '../app/utils';
28+
import { createTableFromText, loadTextDataWrapper, loadBinaryDataWrapper } from '../data/utils';
3329

3430
interface TabPanelProps {
3531
children?: React.ReactNode;
@@ -66,7 +62,6 @@ export const RefreshDataDialog: React.FC<RefreshDataDialogProps> = ({
6662
onRefreshComplete,
6763
}) => {
6864
const theme = useTheme();
69-
const dispatch = useDispatch<AppDispatch>();
7065
const [tabValue, setTabValue] = useState(0);
7166
const [pasteContent, setPasteContent] = useState('');
7267
const [urlContent, setUrlContent] = useState('');

src/views/ReportView.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,9 @@ export const ReportView: FC = () => {
395395
affectedTableIds.forEach(tableId => {
396396
const table = tables.find(t => t.id === tableId);
397397
if (table) {
398-
// Create a signature for the table data
399-
const rowCount = table.rows.length;
400-
const firstRows = JSON.stringify(table.rows.slice(0, 3));
401-
const lastRows = JSON.stringify(table.rows.slice(-2));
402-
const signature = `${rowCount}:${firstRows}:${lastRows}`;
398+
// Use contentHash if available (set by state management), otherwise fallback to lightweight rowCount
399+
// This avoids expensive JSON.stringify operations on every table change during streaming updates
400+
const signature = table.contentHash || `${table.rows.length}`;
403401

404402
const prevSignature = tableRowSignaturesRef.current.get(tableId);
405403
if (prevSignature && prevSignature !== signature) {
@@ -411,7 +409,6 @@ export const ReportView: FC = () => {
411409

412410
// If data changed, regenerate chart images for the report
413411
if (hasChanges) {
414-
console.log('[ReportView] Table data changed, refreshing chart images...');
415412

416413
reportChartIds.forEach(chartId => {
417414
const chart = charts.find(c => c.id === chartId);

src/views/UnifiedDataUploadDialog.tsx

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,6 @@ export const UnifiedDataUploadDialog: React.FC<UnifiedDataUploadDialogProps> = (
473473

474474
// Paste tab state
475475
const [pasteContent, setPasteContent] = useState<string>("");
476-
const [displayContent, setDisplayContent] = useState<string>("");
477476
const [isLargeContent, setIsLargeContent] = useState<boolean>(false);
478477
const [showFullContent, setShowFullContent] = useState<boolean>(false);
479478
const [isOverSizeLimit, setIsOverSizeLimit] = useState<boolean>(false);
@@ -595,7 +594,6 @@ export const UnifiedDataUploadDialog: React.FC<UnifiedDataUploadDialogProps> = (
595594
const handleClose = useCallback(() => {
596595
// Reset state when closing
597596
setPasteContent("");
598-
setDisplayContent("");
599597
setIsLargeContent(false);
600598
setIsOverSizeLimit(false);
601599
setShowFullContent(false);
@@ -753,27 +751,15 @@ export const UnifiedDataUploadDialog: React.FC<UnifiedDataUploadDialogProps> = (
753751
const isLarge = newContent.length > LARGE_CONTENT_THRESHOLD;
754752
setIsLargeContent(isLarge);
755753

756-
if (isLarge && !showFullContent) {
757-
const lines = newContent.split('\n');
758-
const previewLines = lines.slice(0, MAX_DISPLAY_LINES);
759-
const preview = previewLines.join('\n') + (lines.length > MAX_DISPLAY_LINES ? '\n... (truncated for performance)' : '');
760-
setDisplayContent(preview);
761-
} else {
762-
setDisplayContent(newContent);
754+
// If switching from large to small content, ensure full content is shown
755+
if (!isLarge) {
756+
setShowFullContent(true);
763757
}
764-
}, [showFullContent, MAX_CONTENT_SIZE]);
758+
}, []);
765759

766760
const toggleFullContent = useCallback(() => {
767761
setShowFullContent(!showFullContent);
768-
if (!showFullContent) {
769-
setDisplayContent(pasteContent);
770-
} else {
771-
const lines = pasteContent.split('\n');
772-
const previewLines = lines.slice(0, MAX_DISPLAY_LINES);
773-
const preview = previewLines.join('\n') + (lines.length > MAX_DISPLAY_LINES ? '\n... (truncated for performance)' : '');
774-
setDisplayContent(preview);
775-
}
776-
}, [showFullContent, pasteContent]);
762+
}, [showFullContent]);
777763

778764
const handlePasteSubmit = (): void => {
779765
let table: undefined | DictTable = undefined;
@@ -1401,9 +1387,12 @@ export const UnifiedDataUploadDialog: React.FC<UnifiedDataUploadDialogProps> = (
14011387
autoFocus
14021388
multiline
14031389
fullWidth
1404-
value={displayContent}
1390+
value={pasteContent}
14051391
onChange={handleContentChange}
14061392
placeholder="Paste your data here (CSV, TSV, or JSON format)"
1393+
InputProps={{
1394+
readOnly: isLargeContent && !showFullContent,
1395+
}}
14071396
sx={{
14081397
flex: hasPasteContent ? 1 : 'none',
14091398
'& .MuiInputBase-root': {
@@ -1415,9 +1404,27 @@ export const UnifiedDataUploadDialog: React.FC<UnifiedDataUploadDialogProps> = (
14151404
fontFamily: 'monospace',
14161405
height: hasPasteContent ? '100% !important' : 'auto !important',
14171406
overflow: 'auto !important',
1407+
},
1408+
'& .MuiInputBase-input[readonly]': {
1409+
cursor: 'not-allowed',
14181410
}
14191411
}}
14201412
/>
1413+
{/* Show preview indicator when in preview mode */}
1414+
{isLargeContent && !showFullContent && (
1415+
<Box sx={{
1416+
mt: 0.5,
1417+
px: 1,
1418+
py: 0.5,
1419+
backgroundColor: alpha(theme.palette.info.main, 0.08),
1420+
borderRadius: 0.5,
1421+
border: `1px solid ${alpha(theme.palette.info.main, 0.2)}`
1422+
}}>
1423+
<Typography variant="caption" color="text.secondary" sx={{ fontSize: '0.7rem' }}>
1424+
Preview mode: Editing disabled. Click "Show Full" to enable editing.
1425+
</Typography>
1426+
</Box>
1427+
)}
14211428
</Box>
14221429

14231430
<Box sx={{ display: 'flex', justifyContent: 'flex-end', mt: 2, gap: 1 }}>

0 commit comments

Comments
 (0)