refactor: move view recoil states to ui/view-bar folder (#1482)
* refactor: move view recoil states to ui/view-bar folder Closes #1481 * refactor: rename some view related Recoil states and selectors
This commit is contained in:
@ -2,8 +2,10 @@ import { Context, useCallback } from 'react';
|
||||
import { useRecoilState, useRecoilValue } from 'recoil';
|
||||
|
||||
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
||||
import { savedSortsScopedState } from '@/ui/view-bar/states/savedSortsScopedState';
|
||||
import { savedSortsByKeyScopedSelector } from '@/ui/view-bar/states/selectors/savedSortsByKeyScopedSelector';
|
||||
import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue';
|
||||
import { currentViewIdScopedState } from '@/ui/view-bar/states/currentViewIdScopedState';
|
||||
import { savedSortsFamilyState } from '@/ui/view-bar/states/savedSortsFamilyState';
|
||||
import { savedSortsByKeyFamilySelector } from '@/ui/view-bar/states/selectors/savedSortsByKeyFamilySelector';
|
||||
import { sortsScopedState } from '@/ui/view-bar/states/sortsScopedState';
|
||||
import type { SelectedSortType, SortType } from '@/ui/view-bar/types/interface';
|
||||
import {
|
||||
@ -17,24 +19,26 @@ import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
|
||||
export const useViewSorts = <SortField>({
|
||||
availableSorts,
|
||||
currentViewId,
|
||||
scopeContext,
|
||||
skipFetch,
|
||||
}: {
|
||||
availableSorts: SortType<SortField>[];
|
||||
currentViewId: string | undefined;
|
||||
scopeContext: Context<string | null>;
|
||||
skipFetch?: boolean;
|
||||
}) => {
|
||||
const currentViewId = useRecoilScopedValue(
|
||||
currentViewIdScopedState,
|
||||
scopeContext,
|
||||
);
|
||||
const [sorts, setSorts] = useRecoilScopedState(
|
||||
sortsScopedState,
|
||||
scopeContext,
|
||||
);
|
||||
const [, setSavedSorts] = useRecoilState(
|
||||
savedSortsScopedState(currentViewId),
|
||||
savedSortsFamilyState(currentViewId),
|
||||
);
|
||||
const savedSortsByKey = useRecoilValue(
|
||||
savedSortsByKeyScopedSelector(currentViewId),
|
||||
savedSortsByKeyFamilySelector(currentViewId),
|
||||
);
|
||||
|
||||
const { refetch } = useGetViewSortsQuery({
|
||||
|
||||
Reference in New Issue
Block a user