mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-18 06:47:02 +08:00
feat(core): add blocksuite writer info service (#10754)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
export * from './types';
|
||||
export * from './user-list-service';
|
||||
export * from './user-service';
|
||||
export * from './writer-info-service';
|
||||
|
||||
@@ -5,7 +5,6 @@ import type { Signal } from '@preact/signals-core';
|
||||
import type { AffineUserInfo } from './types';
|
||||
|
||||
export interface UserService {
|
||||
getCurrentUser(): AffineUserInfo | null;
|
||||
userInfo$(id: string): Signal<AffineUserInfo | null>;
|
||||
revalidateUserInfo(id: string): void;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { createIdentifier } from '@blocksuite/global/di';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
|
||||
import type { AffineUserInfo } from './types';
|
||||
|
||||
export interface WriterInfoService {
|
||||
getWriterInfo(): AffineUserInfo | null;
|
||||
}
|
||||
|
||||
export const WriterInfoProvider = createIdentifier<WriterInfoService>(
|
||||
'affine-writer-info-service'
|
||||
);
|
||||
|
||||
export function WriterInfoServiceExtension(
|
||||
service: WriterInfoService
|
||||
): ExtensionType {
|
||||
return {
|
||||
setup(di) {
|
||||
di.addImpl(WriterInfoProvider, () => service);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user