Add coreView state in FE (#14034)
Co-authored-by: bosiraphael <raphael.bosi@gmail.com> Co-authored-by: Raphaël Bosi <71827178+bosiraphael@users.noreply.github.com>
This commit is contained in:
@@ -19,6 +19,8 @@ import { getDateFormatFromWorkspaceDateFormat } from '@/localization/utils/getDa
|
||||
import { getTimeFormatFromWorkspaceTimeFormat } from '@/localization/utils/getTimeFormatFromWorkspaceTimeFormat';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { getDateFnsLocale } from '@/ui/field/display/utils/getDateFnsLocale.util';
|
||||
import { coreViewsState } from '@/views/states/coreViewState';
|
||||
import { type CoreViewWithRelations } from '@/views/types/CoreViewWithRelations';
|
||||
import { type ColorScheme } from '@/workspace-member/types/WorkspaceMember';
|
||||
import { enUS } from 'date-fns/locale';
|
||||
import { useEffect } from 'react';
|
||||
@@ -32,6 +34,7 @@ import {
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { dateLocaleState } from '~/localization/states/dateLocaleState';
|
||||
import { dynamicActivate } from '~/utils/i18n/dynamicActivate';
|
||||
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
import { isMatchingLocation } from '~/utils/isMatchingLocation';
|
||||
|
||||
export const UserProviderEffect = () => {
|
||||
@@ -63,6 +66,20 @@ export const UserProviderEffect = () => {
|
||||
[],
|
||||
);
|
||||
|
||||
const setCoreViews = useRecoilCallback(
|
||||
({ set, snapshot }) =>
|
||||
(coreViews: CoreViewWithRelations[]) => {
|
||||
const existingCoreViews = snapshot
|
||||
.getLoadable(coreViewsState)
|
||||
.getValue();
|
||||
|
||||
if (!isDeeplyEqual(existingCoreViews, coreViews)) {
|
||||
set(coreViewsState, coreViews);
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const setCurrentWorkspaceMember = useSetRecoilState(
|
||||
currentWorkspaceMemberState,
|
||||
);
|
||||
@@ -110,6 +127,10 @@ export const UserProviderEffect = () => {
|
||||
});
|
||||
}
|
||||
|
||||
if (isDefined(queryData.currentUser?.currentWorkspace?.views)) {
|
||||
setCoreViews(queryData.currentUser.currentWorkspace.views);
|
||||
}
|
||||
|
||||
const {
|
||||
workspaceMember,
|
||||
workspaceMembers,
|
||||
@@ -181,7 +202,8 @@ export const UserProviderEffect = () => {
|
||||
setDateTimeFormat,
|
||||
setCurrentWorkspaceMembersWithDeleted,
|
||||
updateLocaleCatalog,
|
||||
setCoreViews,
|
||||
]);
|
||||
|
||||
return <></>;
|
||||
return null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user