mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-15 00:56:26 +08:00
19 lines
595 B
TypeScript
19 lines
595 B
TypeScript
import assert from 'assert';
|
|
import { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
|
|
import { getDefaultHeadImgBlob } from '../utils/index.js';
|
|
|
|
export const setDefaultAvatar = async (
|
|
blocksuiteWorkspace: BlocksuiteWorkspace
|
|
) => {
|
|
if (typeof document === 'undefined') {
|
|
return;
|
|
}
|
|
const blob = await getDefaultHeadImgBlob(blocksuiteWorkspace.meta.name);
|
|
const blobStorage = await blocksuiteWorkspace.blobs;
|
|
assert(blobStorage, 'No blob storage');
|
|
const avatar = await blobStorage.set(blob);
|
|
if (avatar) {
|
|
blocksuiteWorkspace.meta.setAvatar(avatar);
|
|
}
|
|
};
|