Fix filters and sorts on views (#2258)

This commit is contained in:
Charles Bochet
2023-10-27 11:48:38 +02:00
committed by GitHub
parent 1728045be4
commit d02dd69613
11 changed files with 90 additions and 64 deletions

View File

@ -1,26 +0,0 @@
import { selectorFamily } from 'recoil';
import { reduceSortsToOrderBy } from '@/ui/data/sort/utils/helpers';
import { SortOrder } from '~/generated/graphql';
import { currentViewSortsScopedFamilyState } from '../currentViewSortsScopedFamilyState';
export const currentViewSortsOrderByScopedFamilySelector = selectorFamily({
key: 'currentViewSortsOrderByScopedFamilySelector',
get:
({ viewScopeId, viewId }: { viewScopeId: string; viewId?: string }) =>
({ get }) => {
if (!viewId) {
return;
}
const orderBy = reduceSortsToOrderBy(
get(
currentViewSortsScopedFamilyState({
scopeId: viewScopeId,
familyKey: viewId,
}),
),
);
return orderBy.length ? orderBy : [{ createdAt: SortOrder.Desc }];
},
});