## Description Several changes made to enhance the table performance: - Batch updates of meta properties to limit the number of rerenders - Removed expensive comparator operations. - Memoised components which are not susceptible to updates. - Table filter code optimisation to limit the number of times setState is triggered. Fixes #20910
119 lines
2.9 KiB
TypeScript
119 lines
2.9 KiB
TypeScript
import type { ReduxAction } from "@appsmith/constants/ReduxActionConstants";
|
|
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
|
|
import type { BatchAction } from "actions/batchActions";
|
|
import { batchAction } from "actions/batchActions";
|
|
import type { EvalMetaUpdates } from "@appsmith/workers/common/DataTreeEvaluator/types";
|
|
import type {
|
|
WidgetEntity,
|
|
DataTreeEntityConfig,
|
|
WidgetEntityConfig,
|
|
} from "../entities/DataTree/dataTreeFactory";
|
|
|
|
export interface UpdateWidgetMetaPropertyPayload {
|
|
widgetId: string;
|
|
propertyName: string;
|
|
propertyValue: unknown;
|
|
}
|
|
|
|
export interface BatchUpdateWidgetMetaPropertyPayload {
|
|
batchMetaUpdates: UpdateWidgetMetaPropertyPayload[];
|
|
}
|
|
export const updateWidgetMetaPropAndEval = (
|
|
widgetId: string,
|
|
propertyName: string,
|
|
propertyValue: unknown,
|
|
): BatchAction<UpdateWidgetMetaPropertyPayload> => {
|
|
return batchAction({
|
|
type: ReduxActionTypes.SET_META_PROP_AND_EVAL,
|
|
payload: {
|
|
widgetId,
|
|
propertyName,
|
|
propertyValue,
|
|
},
|
|
});
|
|
};
|
|
|
|
export type ResetWidgetMetaPayload = {
|
|
widgetId: string;
|
|
evaluatedWidget: WidgetEntity | undefined;
|
|
evaluatedWidgetConfig: DataTreeEntityConfig | undefined;
|
|
};
|
|
|
|
export const resetWidgetMetaProperty = (
|
|
widgetId: string,
|
|
evaluatedWidget: WidgetEntity | undefined,
|
|
evaluatedWidgetConfig: WidgetEntityConfig | undefined,
|
|
): BatchAction<ResetWidgetMetaPayload> => {
|
|
return batchAction({
|
|
type: ReduxActionTypes.RESET_WIDGET_META,
|
|
payload: {
|
|
widgetId,
|
|
evaluatedWidget,
|
|
evaluatedWidgetConfig,
|
|
},
|
|
postEvalActions: [{ type: ReduxActionTypes.RESET_WIDGET_META_EVALUATED }],
|
|
});
|
|
};
|
|
|
|
export const resetChildrenMetaProperty = (
|
|
widgetId: string,
|
|
): ReduxAction<{ widgetId: string }> => {
|
|
return {
|
|
type: ReduxActionTypes.RESET_CHILDREN_WIDGET_META,
|
|
payload: {
|
|
widgetId,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const updateMetaState = (evalMetaUpdates: EvalMetaUpdates) => {
|
|
return {
|
|
type: ReduxActionTypes.UPDATE_META_STATE,
|
|
payload: {
|
|
evalMetaUpdates,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const triggerEvalOnMetaUpdate = () => {
|
|
return batchAction({
|
|
type: ReduxActionTypes.META_UPDATE_DEBOUNCED_EVAL,
|
|
payload: {},
|
|
});
|
|
};
|
|
|
|
export const syncBatchUpdateWidgetMetaProperties = (
|
|
batchMetaUpdates: UpdateWidgetMetaPropertyPayload[],
|
|
): ReduxAction<BatchUpdateWidgetMetaPropertyPayload> => {
|
|
return {
|
|
type: ReduxActionTypes.BATCH_UPDATE_META_PROPS,
|
|
payload: { batchMetaUpdates },
|
|
};
|
|
};
|
|
|
|
export const syncUpdateWidgetMetaProperty = (
|
|
widgetId: string,
|
|
propertyName: string,
|
|
propertyValue: unknown,
|
|
) => {
|
|
return {
|
|
type: ReduxActionTypes.SET_META_PROP,
|
|
payload: {
|
|
widgetId,
|
|
propertyName,
|
|
propertyValue,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const resetWidgetsMetaState = (
|
|
widgetIdsToClear: string[],
|
|
): ReduxAction<{ widgetIdsToClear: string[] }> => {
|
|
return {
|
|
type: ReduxActionTypes.RESET_WIDGETS_META_STATE,
|
|
payload: {
|
|
widgetIdsToClear,
|
|
},
|
|
};
|
|
};
|