Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(core): should log in before accepting the invitation (#9150)

JimmFly0de7782c9b6c
diff --git a/packages/frontend/core/src/desktop/pages/invite/index.tsx b/packages/frontend/core/src/desktop/pages/invite/index.tsx
index e8f4ad98e8..2f97fe26e8 100644
--- a/packages/frontend/core/src/desktop/pages/invite/index.tsx
+++ b/packages/frontend/core/src/desktop/pages/invite/index.tsx
@@ -25,50 +25,44 @@ const AcceptInvite = ({
}: {
inviteInfo: GetInviteInfoQuery['getInviteInfo'];
}) => {
+ const { jumpToPage } = useNavigateHelper();
+
+ const openWorkspace = useCallback(() => {
+ jumpToPage(inviteInfo.workspace.id, 'all', RouteLogic.REPLACE);
+ }, [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();
- const { jumpToPage } = useNavigateHelper();
-
- const openWorkspace = useCallback(() => {
- jumpToPage(inviteInfo.workspace.id, 'all', RouteLogic.REPLACE);
- }, [inviteInfo.workspace.id, jumpToPage]);
useEffect(() => {
if (loginStatus === 'unauthenticated' && !isRevalidating) {
// We can not pass function to navigate state, so we need to save it in atom
- jumpToSignIn(
- `/workspace/${inviteInfo.workspace.id}/all`,
- RouteLogic.REPLACE
- );
+ jumpToSignIn(`/invite/${params.inviteId}`, RouteLogic.REPLACE);
}
- }, [
- inviteInfo.workspace.id,
- isRevalidating,
- jumpToSignIn,
- loginStatus,
- openWorkspace,
- ]);
+ }, [isRevalidating, jumpToSignIn, loginStatus, params.inviteId]);
if (loginStatus === 'authenticated') {
- return (
- <AcceptInvitePage
- inviteInfo={inviteInfo}
- onOpenWorkspace={openWorkspace}
- />
- );
+ return <Middle />;
}
return null;
};
-export const Component = () => {
+export const Middle = () => {
const graphqlService = useService(GraphQLService);
const params = useParams<{ inviteId: string }>();
const navigateHelper = useNavigateHelper();