mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-13 04:42:56 +08:00
feat(core): add public user service (#10695)
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
type PageEditor,
|
||||
} from '@affine/core/blocksuite/editors';
|
||||
import { useEnableAI } from '@affine/core/components/hooks/affine/use-enable-ai';
|
||||
import { AuthService, PublicUserService } from '@affine/core/modules/cloud';
|
||||
import type { DocCustomPropertyInfo } from '@affine/core/modules/db';
|
||||
import { DocService, DocsService } from '@affine/core/modules/doc';
|
||||
import type {
|
||||
@@ -70,6 +71,7 @@ import {
|
||||
type ReferenceReactRenderer,
|
||||
} from '../extensions/reference-renderer';
|
||||
import { patchSideBarService } from '../extensions/side-bar-service';
|
||||
import { patchUserExtensions } from '../extensions/user';
|
||||
import { patchUserListExtensions } from '../extensions/user-list';
|
||||
import { BiDirectionalLinkPanel } from './bi-directional-link-panel';
|
||||
import { BlocksuiteEditorJournalDocTitle } from './journal-doc-title';
|
||||
@@ -93,6 +95,8 @@ const usePatchSpecs = (mode: DocMode) => {
|
||||
workspaceService,
|
||||
featureFlagService,
|
||||
memberSearchService,
|
||||
publicUserService,
|
||||
authService,
|
||||
} = useServices({
|
||||
PeekViewService,
|
||||
DocService,
|
||||
@@ -101,7 +105,10 @@ const usePatchSpecs = (mode: DocMode) => {
|
||||
EditorService,
|
||||
FeatureFlagService,
|
||||
MemberSearchService,
|
||||
PublicUserService,
|
||||
AuthService,
|
||||
});
|
||||
const isCloud = workspaceService.workspace.flavour !== 'local';
|
||||
const framework = useFramework();
|
||||
const referenceRenderer: ReferenceReactRenderer = useMemo(() => {
|
||||
return function customReference(reference) {
|
||||
@@ -155,11 +162,16 @@ const usePatchSpecs = (mode: DocMode) => {
|
||||
patchPeekViewService(peekViewService),
|
||||
patchOpenDocExtension(),
|
||||
EdgelessClipboardWatcher,
|
||||
patchUserListExtensions(memberSearchService),
|
||||
patchDocUrlExtensions(framework),
|
||||
patchQuickSearchService(framework),
|
||||
patchSideBarService(framework),
|
||||
patchDocModeService(docService, docsService, editorService),
|
||||
isCloud
|
||||
? [
|
||||
patchUserListExtensions(memberSearchService),
|
||||
patchUserExtensions(publicUserService, authService),
|
||||
]
|
||||
: [],
|
||||
mode === 'edgeless' && enableTurboRenderer
|
||||
? [ViewportTurboRendererExtension]
|
||||
: [],
|
||||
@@ -185,10 +197,13 @@ const usePatchSpecs = (mode: DocMode) => {
|
||||
referenceRenderer,
|
||||
confirmModal,
|
||||
peekViewService,
|
||||
memberSearchService,
|
||||
docService,
|
||||
docsService,
|
||||
editorService,
|
||||
isCloud,
|
||||
memberSearchService,
|
||||
publicUserService,
|
||||
authService,
|
||||
enableTurboRenderer,
|
||||
featureFlagService.flags.enable_pdf_embed_preview.value,
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import type {
|
||||
AuthService,
|
||||
PublicUserService,
|
||||
} from '@affine/core/modules/cloud';
|
||||
import { UserServiceExtension } from '@blocksuite/affine/blocks';
|
||||
|
||||
export function patchUserExtensions(
|
||||
publicUserService: PublicUserService,
|
||||
authService: AuthService
|
||||
) {
|
||||
return UserServiceExtension({
|
||||
getCurrentUser() {
|
||||
const account = authService.session.account$.value;
|
||||
return account
|
||||
? {
|
||||
id: account.id,
|
||||
avatar: account.avatar,
|
||||
name: account.label,
|
||||
}
|
||||
: null;
|
||||
},
|
||||
// eslint-disable-next-line rxjs/finnish
|
||||
userInfo$(id) {
|
||||
return publicUserService.publicUser$(id).signal;
|
||||
},
|
||||
revalidateUserInfo(id) {
|
||||
publicUserService.revalidate(id);
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user