mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-28 15:55:19 +08:00
feat(core): doc level awareness (#10646)
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
import { WorkspaceService } from '@affine/core/modules/workspace';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { AuthService } from '../../../modules/cloud';
|
||||
|
||||
const SyncAwarenessInnerLoggedIn = () => {
|
||||
const authService = useService(AuthService);
|
||||
const account = useLiveData(authService.session.account$);
|
||||
const currentWorkspace = useService(WorkspaceService).workspace;
|
||||
|
||||
useEffect(() => {
|
||||
if (account && currentWorkspace) {
|
||||
currentWorkspace.docCollection.awarenessStore.awareness.setLocalStateField(
|
||||
'user',
|
||||
{
|
||||
name: account.label,
|
||||
// TODO(@eyhn): add avatar?
|
||||
}
|
||||
);
|
||||
|
||||
return () => {
|
||||
currentWorkspace.docCollection.awarenessStore.awareness.setLocalStateField(
|
||||
'user',
|
||||
null
|
||||
);
|
||||
};
|
||||
}
|
||||
return;
|
||||
}, [currentWorkspace, account]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const SyncAwarenessInner = () => {
|
||||
const session = useService(AuthService).session;
|
||||
const loginStatus = useLiveData(session.status$);
|
||||
|
||||
if (loginStatus === 'authenticated') {
|
||||
return <SyncAwarenessInnerLoggedIn />;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
// TODO(@eyhn): we could do something more interesting here, e.g., show where the current user is
|
||||
export const SyncAwareness = () => {
|
||||
return <SyncAwarenessInner />;
|
||||
};
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
CopilotClient,
|
||||
setupAIProvider,
|
||||
} from '@affine/core/blocksuite/ai';
|
||||
import { SyncAwareness } from '@affine/core/components/affine/awareness';
|
||||
import { useRegisterFindInPageCommands } from '@affine/core/components/hooks/affine/use-register-find-in-page-commands';
|
||||
import { useRegisterWorkspaceCommands } from '@affine/core/components/hooks/use-register-workspace-commands';
|
||||
import { OverCapacityNotification } from '@affine/core/components/over-capacity';
|
||||
@@ -176,7 +175,6 @@ export const WorkspaceSideEffects = () => {
|
||||
return (
|
||||
<>
|
||||
<QuickSearchContainer />
|
||||
<SyncAwareness />
|
||||
<OverCapacityNotification />
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user