Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/containers/Tenant/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export const MAX_QUERY_HEIGHT = 6;

export const QUERY_TABLE_SETTINGS: Settings = {
...DEFAULT_TABLE_SETTINGS,
dynamicRenderType: 'variable',
dynamicRenderType: 'simple',
};
22 changes: 13 additions & 9 deletions src/store/reducers/query/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,6 @@ const slice = createSlice({
selectResult: (state) => state.result,
selectStartTime: (state) => state.result?.startTime,
selectEndTime: (state) => state.result?.endTime,
selectQueriesHistory: (state) => {
const items = state.history.queries;
const filter = state.history.filter?.toLowerCase();

return filter
? items.filter((item) => item.queryText.toLowerCase().includes(filter))
: items;
},
selectUserInput: (state) => state.input,
selectIsDirty: (state) => state.isDirty,
selectQueriesHistoryCurrentIndex: (state) => state.history?.currentIndex,
Expand All @@ -174,6 +166,19 @@ export const selectQueryDuration = createSelector(
},
);

export const selectQueriesHistory = createSelector(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, explain, why these changes are needed? I see no difference

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous realization caused errors Selector wrapper returned a different result when called with the same parameters. This can lead to unnecessary rerenders. Selectors that return a new reference (such as an object or an array) should be memoized And this caused total freeze of the page.

[
(state: RootState) => state.query.history.queries,
(state: RootState) => state.query.history.filter,
],
(queries, filter) => {
const normalizedFilter = filter?.toLowerCase();
return normalizedFilter
? queries.filter((item) => item.queryText.toLowerCase().includes(normalizedFilter))
: queries;
},
);

export default slice.reducer;
export const {
changeUserInput,
Expand All @@ -194,7 +199,6 @@ export const {
export const {
selectQueriesHistoryFilter,
selectQueriesHistoryCurrentIndex,
selectQueriesHistory,
selectTenantPath,
selectResult,
selectUserInput,
Expand Down
Loading