Use scoped recoil state for email thread page (#3699)

Use scoped recoild state for email thread page

Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
Thomas Trompette
2024-01-30 17:08:34 +01:00
committed by GitHub
parent 2f7f6d3241
commit 1838d8e6fb
4 changed files with 51 additions and 18 deletions

View File

@ -0,0 +1,22 @@
import { emailThreadsPageStateScopeMap } from '@/activities/emails/state/emailThreadsPageStateScopeMap';
import { TabListScopeInternalContext } from '@/ui/layout/tab/scopes/scope-internal-context/TabListScopeInternalContext';
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
import { getState } from '@/ui/utilities/recoil-scope/utils/getState';
type useEmailThreadStatesProps = {
emailThreadScopeId?: string;
};
export const useEmailThreadStates = ({
emailThreadScopeId,
}: useEmailThreadStatesProps) => {
const scopeId = useAvailableScopeIdOrThrow(
TabListScopeInternalContext,
emailThreadScopeId,
);
return {
scopeId,
getEmailThreadsPageState: getState(emailThreadsPageStateScopeMap, scopeId),
};
};