perf: apply record optimistic effects with cache.modify on mutation (#3540)
* perf: apply record optimistic effects with cache.modify on mutation Closes #3509 * refactor: return early when created records do not match filter * fix: fix id generation on record creation * fix: comment filtering behavior on record creation * Fixed typing error * refactor: review - use ?? * refactor: review - add variables in readFieldValueToSort * docs: review - add comments for variables.first in triggerUpdateRecordOptimisticEffect * refactor: review - add intermediary variable for 'not' filter in useMultiObjectSearchMatchesSearchFilterAndToSelectQuery * refactor: review - add filter utils * fix: fix tests --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
21
packages/twenty-front/src/utils/sort.ts
Normal file
21
packages/twenty-front/src/utils/sort.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { Maybe } from '~/generated/graphql';
|
||||
|
||||
export const sortNullsFirst = (
|
||||
fieldValueA: Maybe<unknown>,
|
||||
fieldValueB: Maybe<unknown>,
|
||||
) => (fieldValueA === null ? -1 : fieldValueB === null ? 1 : 0);
|
||||
|
||||
export const sortNullsLast = (
|
||||
fieldValueA: Maybe<unknown>,
|
||||
fieldValueB: Maybe<unknown>,
|
||||
) => sortNullsFirst(fieldValueB, fieldValueA);
|
||||
|
||||
export const sortAsc = (
|
||||
fieldValueA: string | number,
|
||||
fieldValueB: string | number,
|
||||
) => (fieldValueA < fieldValueB ? -1 : 1);
|
||||
|
||||
export const sortDesc = (
|
||||
fieldValueA: string | number,
|
||||
fieldValueB: string | number,
|
||||
) => sortAsc(fieldValueB, fieldValueA);
|
||||
Reference in New Issue
Block a user