Files
twenty/packages/twenty-shared
Félix Malfait ff2f86848c refactor(filters): introduce findFieldMetadataItemByIdSelector and drop createFindFieldMetadataItemById helper
The convenience helper was a sign that callers were each reindexing the
same workspace-wide flat field metadata array into the same lookup map.
The fix is upstream: derive the lookup once in a Jotai selector and
remove the helper.

- New `findFieldMetadataItemByIdSelector` (twenty-front) builds the id
  index once from `flattenedFieldMetadataItemsSelector` and returns a
  `FindFieldMetadataItemById` callback.
- All 10 Jotai-using callers (record-table SSE, record-table empty,
  table-column-footer, record-index group-by, group common variables,
  table params, graph widget, calendar date range, total count) pull
  the callback from the selector instead of indexing themselves.
- Two pure utilities (`computeContextStoreFilters`,
  `getQueryVariablesFromFiltersAndSorts`) now take
  `findFieldMetadataItemById` directly; their 6 callers pass it from
  the selector (or `store.get` for the non-React path).
- `useFindManyRecordsSelectedInContextStore` also routes the
  `deletedAt` lookup through the resolver instead of re-flattening.
- `turnAnyFieldFilterIntoRecordGqlFilter` (twenty-shared) and
  `buildRowLevelPermissionRecordFilter` (twenty-server) inline the
  resolver — the server one collapses to a one-liner against
  `flatFieldMetadataMaps`, dropping the per-predicate field-id
  remapping it used to do.
- Dispatcher tests inline `Map`-backed resolvers.
- `createFindFieldMetadataItemById` and its exports are deleted.
2026-05-18 15:13:29 +02:00
..