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:
@ -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),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user