Skip to content

Commit 7b36f31

Browse files
committed
fix: interface shaking
1 parent 46d6868 commit 7b36f31

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

src/components/QueryResultTable/QueryResultTable.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@
99
&__message {
1010
padding: 15px 10px;
1111
}
12+
13+
// Must have fixed height for frequent data updates (to avoid interface shaking).
14+
// Will be fixed after migration to new @gravity-ui/table.
15+
&__table-wrapper {
16+
height: 0px;
17+
}
1218
}

src/components/QueryResultTable/QueryResultTable.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export const QueryResultTable = (props: QueryResultTableProps) => {
104104
// prevent accessing row.id in case it is present but is not the PK (i.e. may repeat)
105105
rowKey={getRowIndex}
106106
visibleRowIndex={getVisibleRowIndex}
107+
wrapperClassName={b('table-wrapper')}
107108
{...restProps}
108109
/>
109110
);

src/store/reducers/query/streamingReducers.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ const updateSpeedMetrics = (metrics: SpeedMetrics, totalNewRows: number) => {
8080
metrics.lastUpdateTime = currentTime;
8181
};
8282

83+
const getEmptyResultSet = () => {
84+
return {
85+
columns: [],
86+
result: [],
87+
truncated: false,
88+
speedMetrics: {
89+
rowsPerSecond: 0,
90+
lastUpdateTime: Date.now(),
91+
recentChunks: [],
92+
},
93+
};
94+
};
95+
8396
export const addStreamingChunks = (state: QueryState, action: PayloadAction<StreamDataChunk[]>) => {
8497
if (!state.result) {
8598
return;
@@ -118,18 +131,12 @@ export const addStreamingChunks = (state: QueryState, action: PayloadAction<Stre
118131
// Process merged chunks
119132
for (const [resultIndex, chunk] of mergedChunks.entries()) {
120133
const {columns, rows} = chunk.result;
121-
const resultSet = (state.result.data.resultSets[resultIndex] = state.result.data.resultSets[
122-
resultIndex
123-
] || {
124-
columns: [],
125-
result: [],
126-
truncated: false,
127-
speedMetrics: {
128-
rowsPerSecond: 0,
129-
lastUpdateTime: Date.now(),
130-
recentChunks: [],
131-
},
132-
});
134+
const resultSets = state.result.data.resultSets;
135+
136+
if (!resultSets[resultIndex]) {
137+
resultSets[resultIndex] = getEmptyResultSet();
138+
}
139+
const resultSet = resultSets[resultIndex];
133140

134141
if (columns && !resultSet.columns?.length) {
135142
resultSet.columns = columns;

0 commit comments

Comments
 (0)