fix(core): handle invitation failure (#11195)
This commit is contained in:
@@ -25,13 +25,14 @@ export const JoinFailedPage = ({
|
|||||||
i18nKey={'com.affine.fail-to-join-workspace.description-1'}
|
i18nKey={'com.affine.fail-to-join-workspace.description-1'}
|
||||||
components={{
|
components={{
|
||||||
1: (
|
1: (
|
||||||
|
<div className={styles.avatarWrapper}>
|
||||||
<Avatar
|
<Avatar
|
||||||
url={`data:image/png;base64,${inviteInfo.workspace.avatar}`}
|
url={`data:image/png;base64,${inviteInfo.workspace.avatar}`}
|
||||||
name={inviteInfo.workspace.name}
|
name={inviteInfo.workspace.name}
|
||||||
size={20}
|
size={20}
|
||||||
style={{ marginLeft: 4 }}
|
|
||||||
colorfulFallback
|
colorfulFallback
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
),
|
),
|
||||||
2: <span className={styles.inviteName} />,
|
2: <span className={styles.inviteName} />,
|
||||||
}}
|
}}
|
||||||
@@ -42,7 +43,11 @@ export const JoinFailedPage = ({
|
|||||||
<div>{t['com.affine.fail-to-join-workspace.description-2']()}</div>
|
<div>{t['com.affine.fail-to-join-workspace.description-2']()}</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div>{t['error.' + userFriendlyError.name]()}</div>
|
<div>
|
||||||
|
{t['error.' + userFriendlyError.name]()}
|
||||||
|
<br />
|
||||||
|
{userFriendlyError.message}
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -355,6 +355,7 @@ const InvitationNotificationItem = ({
|
|||||||
// ignore if the user is already in the workspace
|
// ignore if the user is already in the workspace
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
notify.error(userFriendlyError);
|
||||||
throw err;
|
throw err;
|
||||||
})
|
})
|
||||||
.then(async value => {
|
.then(async value => {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { notify } from '@affine/component';
|
||||||
import {
|
import {
|
||||||
AcceptInvitePage,
|
AcceptInvitePage,
|
||||||
ExpiredPage,
|
ExpiredPage,
|
||||||
@@ -34,6 +35,9 @@ const AcceptInvite = ({ inviteId: targetInviteId }: { inviteId: string }) => {
|
|||||||
const workspaces = useLiveData(workspacesService.list.workspaces$);
|
const workspaces = useLiveData(workspacesService.list.workspaces$);
|
||||||
const navigateHelper = useNavigateHelper();
|
const navigateHelper = useNavigateHelper();
|
||||||
const [accepted, setAccepted] = useState(false);
|
const [accepted, setAccepted] = useState(false);
|
||||||
|
const [acceptError, setAcceptError] = useState<UserFriendlyError | null>(
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
const openWorkspace = useAsyncCallback(async () => {
|
const openWorkspace = useAsyncCallback(async () => {
|
||||||
if (!inviteInfo?.workspace.id) {
|
if (!inviteInfo?.workspace.id) {
|
||||||
@@ -70,6 +74,8 @@ const AcceptInvite = ({ inviteId: targetInviteId }: { inviteId: string }) => {
|
|||||||
if (err.is('ALREADY_IN_SPACE')) {
|
if (err.is('ALREADY_IN_SPACE')) {
|
||||||
return openWorkspace();
|
return openWorkspace();
|
||||||
}
|
}
|
||||||
|
setAcceptError(err);
|
||||||
|
notify.error(err);
|
||||||
});
|
});
|
||||||
}, [invitationService, openWorkspace, targetInviteId]);
|
}, [invitationService, openWorkspace, targetInviteId]);
|
||||||
|
|
||||||
@@ -85,8 +91,10 @@ const AcceptInvite = ({ inviteId: targetInviteId }: { inviteId: string }) => {
|
|||||||
return <ExpiredPage onOpenAffine={onOpenAffine} />;
|
return <ExpiredPage onOpenAffine={onOpenAffine} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error || acceptError) {
|
||||||
return <JoinFailedPage inviteInfo={inviteInfo} error={error} />;
|
return (
|
||||||
|
<JoinFailedPage inviteInfo={inviteInfo} error={error || acceptError} />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for email invite
|
// for email invite
|
||||||
|
|||||||
Reference in New Issue
Block a user