Open nidhi-nair opened 2 years ago
From chatgpt:
Here is the complete list of redundant selectors found in both widgetSelectors.ts
and selectors.tsx
:
getExistingWidgetNames
widgetSelectors.ts
and selectors.tsx
.getFocusedWidget
widgetSelectors.ts
and selectors.tsx
.getWidgets
widgetSelectors.ts
and selectors.tsx
.getExistingWidgetNames
widgetSelectors.ts
import { getExistingWidgetNames } from "sagas/selectors"; // ... export const getExistingWidgetNames = createSelector( getWidgets, (widgets: { [widgetId: string]: FlattenedWidgetProps }) => { return Object.values(widgets).map((widget) => widget.widgetName); }, );
selectors.tsx
export const getExistingWidgetNames = createSelector( getWidgets, (widgets: { [widgetId: string]: FlattenedWidgetProps }) => { return Object.values(widgets).map((widget) => widget.widgetName); }, );
widgetSelectors.ts
const getCanvasWidgets = (state: AppState) => state.entities.canvasWidgets;
selectors.tsx
export const getWidgets = (state: AppState): CanvasWidgetsReduxState => { return state.entities.canvasWidgets; };
To resolve these redundancies, you should keep the selectors in one file and remove or refactor them in the other. Here is an example of what you can do:
• Decide which file should be the primary source for these selectors.
• Remove or refactor the redundant selectors in the other file.
• Ensure that any imports or usages of these selectors are updated accordingly to avoid referencing the removed definitions.
Is there an existing issue for this?
SubTasks
The two files below seem to have redundant selectors:
app/client/src/selectors/widgetSelectors.ts
app/client/src/sagas/selectors.tsx