mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-21 11:21:39 +03:00
fix(core): should log in before accepting the invitation (#9150)
This commit is contained in:
parent
293a155977
commit
0de7782c9b
@ -25,50 +25,44 @@ const AcceptInvite = ({
|
|||||||
}: {
|
}: {
|
||||||
inviteInfo: GetInviteInfoQuery['getInviteInfo'];
|
inviteInfo: GetInviteInfoQuery['getInviteInfo'];
|
||||||
}) => {
|
}) => {
|
||||||
const authService = useService(AuthService);
|
|
||||||
const isRevalidating = useLiveData(authService.session.isRevalidating$);
|
|
||||||
const loginStatus = useLiveData(authService.session.status$);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
authService.session.revalidate();
|
|
||||||
}, [authService]);
|
|
||||||
|
|
||||||
const { jumpToSignIn } = useNavigateHelper();
|
|
||||||
const { jumpToPage } = useNavigateHelper();
|
const { jumpToPage } = useNavigateHelper();
|
||||||
|
|
||||||
const openWorkspace = useCallback(() => {
|
const openWorkspace = useCallback(() => {
|
||||||
jumpToPage(inviteInfo.workspace.id, 'all', RouteLogic.REPLACE);
|
jumpToPage(inviteInfo.workspace.id, 'all', RouteLogic.REPLACE);
|
||||||
}, [inviteInfo.workspace.id, jumpToPage]);
|
}, [inviteInfo.workspace.id, jumpToPage]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AcceptInvitePage inviteInfo={inviteInfo} onOpenWorkspace={openWorkspace} />
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Component = () => {
|
||||||
|
const authService = useService(AuthService);
|
||||||
|
const isRevalidating = useLiveData(authService.session.isRevalidating$);
|
||||||
|
const loginStatus = useLiveData(authService.session.status$);
|
||||||
|
const params = useParams<{ inviteId: string }>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
authService.session.revalidate();
|
||||||
|
}, [authService]);
|
||||||
|
|
||||||
|
const { jumpToSignIn } = useNavigateHelper();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (loginStatus === 'unauthenticated' && !isRevalidating) {
|
if (loginStatus === 'unauthenticated' && !isRevalidating) {
|
||||||
// We can not pass function to navigate state, so we need to save it in atom
|
// We can not pass function to navigate state, so we need to save it in atom
|
||||||
jumpToSignIn(
|
jumpToSignIn(`/invite/${params.inviteId}`, RouteLogic.REPLACE);
|
||||||
`/workspace/${inviteInfo.workspace.id}/all`,
|
|
||||||
RouteLogic.REPLACE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}, [
|
}, [isRevalidating, jumpToSignIn, loginStatus, params.inviteId]);
|
||||||
inviteInfo.workspace.id,
|
|
||||||
isRevalidating,
|
|
||||||
jumpToSignIn,
|
|
||||||
loginStatus,
|
|
||||||
openWorkspace,
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (loginStatus === 'authenticated') {
|
if (loginStatus === 'authenticated') {
|
||||||
return (
|
return <Middle />;
|
||||||
<AcceptInvitePage
|
|
||||||
inviteInfo={inviteInfo}
|
|
||||||
onOpenWorkspace={openWorkspace}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Component = () => {
|
export const Middle = () => {
|
||||||
const graphqlService = useService(GraphQLService);
|
const graphqlService = useService(GraphQLService);
|
||||||
const params = useParams<{ inviteId: string }>();
|
const params = useParams<{ inviteId: string }>();
|
||||||
const navigateHelper = useNavigateHelper();
|
const navigateHelper = useNavigateHelper();
|
||||||
|
Loading…
Reference in New Issue
Block a user