feat: update avatar

This commit is contained in:
DiamondThree
2023-01-10 16:29:37 +08:00
parent 890e353dc7
commit 49dd21de57
4 changed files with 35 additions and 21 deletions
@@ -7,9 +7,17 @@ import { DownloadIcon } from '@blocksuite/icons';
import { Button } from '@/ui/button';
import { Menu, MenuItem } from '@/ui/menu';
import { WorkspaceInfo } from '@affine/datacenter';
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
import { useAppState } from '@/providers/app-state-provider';
import { useConfirm } from '@/providers/ConfirmProvider';
import { toast } from '@/ui/toast';
import { useUserHelper } from '@/hooks/use-user-helper';
export const SyncPage = ({ workspace }: { workspace: WorkspaceInfo }) => {
console.log('workspace: ', workspace);
// console.log('workspace: ', workspace);
const { enableWorkspace } = useWorkspaceHelper();
const { currentWorkspace } = useAppState();
const { confirm } = useConfirm();
const { user, login } = useUserHelper();
return (
<div>
<StyledPublishContent>
@@ -24,9 +32,20 @@ export const SyncPage = ({ workspace }: { workspace: WorkspaceInfo }) => {
<StyledPublishCopyContainer>
<Button
onClick={() => {
// updateWorkspaceMeta(currentWorkspace.id, {
// type: 'cloud',
// });
confirm({
title: 'Enable AFFiNE Cloud?',
content: `If enabled, the data in this workspace will be backed up and synchronized via AFFiNE Cloud.`,
confirmText: user ? 'Enable' : 'Sign in and Enable',
cancelText: 'Skip',
}).then(async confirm => {
if (confirm) {
// if (user) {
// await login();
// }
await enableWorkspace(currentWorkspace);
toast('Enabled success');
}
});
}}
type="primary"
shape="circle"
@@ -47,8 +47,9 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceInfo }) => {
const fileChange = async (file: File) => {
// console.log('file: ', file);
setUploading(true);
// setUploading(true);
const blob = new Blob([file], { type: file.type });
updateWorkspace({ avatarBlob: blob }, currentWorkspace);
};
return workspace ? (