Skip to content

Commit 64e1564

Browse files
authored
fix: performance improvement and less excessive logging. (#246)
* fix: Remove excessive dataframe logging. * fix: Prevent expensive map effects from running on every render
1 parent 283cf29 commit 64e1564

2 files changed

Lines changed: 24 additions & 17 deletions

File tree

src/App.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class App extends React.Component {
6161
selectedRowIndexPerDataset: [-1, -1, -1, -1, -1],
6262
currentLogData: this.props.logData,
6363
dynamicMarkerLocations: {},
64+
visibleToggles: getVisibleToggles(this.props.logData.solutionType),
6465
};
6566
this.onSliderChangeDebounced = _.debounce((timeRange) => this.onSliderChange(timeRange), 25);
6667
this.setFeaturedObject = this.setFeaturedObject.bind(this);
@@ -696,20 +697,21 @@ class App extends React.Component {
696697
const data = await getUploadedData(index);
697698
if (data && data.rawLogs && Array.isArray(data.rawLogs) && data.rawLogs.length > 0) {
698699
const tripLogs = new TripLogs(data.rawLogs, data.solutionType);
700+
const newVisibleToggles = getVisibleToggles(data.solutionType);
701+
699702
this.setState(
700-
(prevState) => {
701-
return {
702-
activeDatasetIndex: index,
703-
timeRange: { minTime: tripLogs.minDate.getTime(), maxTime: tripLogs.maxDate.getTime() },
704-
initialMapBounds: data.bounds,
705-
currentLogData: {
706-
...prevState.currentLogData,
707-
tripLogs: tripLogs,
708-
solutionType: data.solutionType,
709-
},
710-
dynamicMarkerLocations: {}, // Clear markers when switching datasets
711-
};
712-
},
703+
(prevState) => ({
704+
activeDatasetIndex: index,
705+
timeRange: { minTime: tripLogs.minDate.getTime(), maxTime: tripLogs.maxDate.getTime() },
706+
initialMapBounds: data.bounds,
707+
currentLogData: {
708+
...prevState.currentLogData,
709+
tripLogs: tripLogs,
710+
solutionType: data.solutionType,
711+
},
712+
visibleToggles: newVisibleToggles,
713+
dynamicMarkerLocations: {}, // Clear markers when switching datasets
714+
}),
713715
() => {
714716
log(`Switched to dataset ${index}`);
715717
log(`New time range: ${tripLogs.minDate} - ${tripLogs.maxDate}`);
@@ -768,10 +770,16 @@ class App extends React.Component {
768770
}
769771

770772
render() {
771-
const { featuredObject, timeRange, currentLogData, toggleOptions, extraColumns, dynamicMarkerLocations } =
772-
this.state;
773+
const {
774+
featuredObject,
775+
timeRange,
776+
currentLogData,
777+
toggleOptions,
778+
extraColumns,
779+
dynamicMarkerLocations,
780+
visibleToggles,
781+
} = this.state;
773782
const selectedEventTime = featuredObject?.timestamp ? new Date(featuredObject.timestamp).getTime() : null;
774-
const visibleToggles = getVisibleToggles(currentLogData.solutionType);
775783

776784
return (
777785
<div className="app-container">

src/Dataframe.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ function Dataframe({ featuredObject, extraColumns, onColumnToggle, onToggleMarke
153153
}, []);
154154

155155
const shouldCollapse = useCallback(({ indexOrName, depth }) => {
156-
log(`shouldCollapse called for indexOrName: '${indexOrName}', depth: ${depth}`);
157156
if (depth === 1 && typeof indexOrName === "undefined") {
158157
return false;
159158
}

0 commit comments

Comments
 (0)