mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat: send email to owner after member accepted invitation / leave workspace (#4152)
Co-authored-by: DarkSky <darksky2048@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { pushNotificationAtom } from '@affine/component/notification-center';
|
||||
import { WorkspaceSubPath } from '@affine/env/workspace';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
|
||||
import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name';
|
||||
import { usePassiveWorkspaceEffect } from '@toeverything/infra/__internal__/react';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { useAtomValue } from 'jotai';
|
||||
@@ -24,7 +25,11 @@ export const WorkspaceSetting = ({ workspaceId }: { workspaceId: string }) => {
|
||||
|
||||
const { jumpToSubPath, jumpToIndex } = useNavigateHelper();
|
||||
const [currentWorkspace] = useCurrentWorkspace();
|
||||
|
||||
const workspace = useWorkspace(workspaceId);
|
||||
const [workspaceName] = useBlockSuiteWorkspaceName(
|
||||
workspace.blockSuiteWorkspace
|
||||
);
|
||||
const workspaces = useAtomValue(rootWorkspacesMetadataAtom);
|
||||
const pushNotification = useSetAtom(pushNotificationAtom);
|
||||
|
||||
@@ -74,13 +79,19 @@ export const WorkspaceSetting = ({ workspaceId }: { workspaceId: string }) => {
|
||||
|
||||
const handleLeaveWorkspace = useCallback(async () => {
|
||||
closeAndJumpOut();
|
||||
await leaveWorkspace(workspaceId);
|
||||
await leaveWorkspace(workspaceId, workspaceName);
|
||||
|
||||
pushNotification({
|
||||
title: 'Successfully leave',
|
||||
type: 'success',
|
||||
});
|
||||
}, [closeAndJumpOut, leaveWorkspace, pushNotification, workspaceId]);
|
||||
}, [
|
||||
closeAndJumpOut,
|
||||
leaveWorkspace,
|
||||
pushNotification,
|
||||
workspaceId,
|
||||
workspaceName,
|
||||
]);
|
||||
|
||||
const onTransformWorkspace = useOnTransformWorkspace();
|
||||
// const handleDelete = useCallback(async () => {
|
||||
|
||||
@@ -12,10 +12,13 @@ export function useLeaveWorkspace() {
|
||||
});
|
||||
|
||||
return useCallback(
|
||||
async (workspaceId: string) => {
|
||||
async (workspaceId: string, workspaceName: string) => {
|
||||
deleteWorkspaceMeta(workspaceId);
|
||||
|
||||
await leaveWorkspace({
|
||||
workspaceId,
|
||||
workspaceName,
|
||||
sendLeaveMail: true,
|
||||
});
|
||||
},
|
||||
[deleteWorkspaceMeta, leaveWorkspace]
|
||||
|
||||
@@ -35,6 +35,7 @@ export const loader: LoaderFunction = async args => {
|
||||
variables: {
|
||||
workspaceId: res.getInviteInfo.workspace.id,
|
||||
inviteId,
|
||||
sendAcceptMail: true,
|
||||
},
|
||||
}).catch(console.error);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user