mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-03 18:40:00 +08:00
feat(core): user service loading state (#10922)
This commit is contained in:
@@ -346,9 +346,16 @@ function createToolbarMoreMenuConfigV2(baseUrl?: string) {
|
||||
const userProvider = cx.std.get(UserProvider);
|
||||
userProvider.revalidateUserInfo(createdByUserId);
|
||||
const userSignal = userProvider.userInfo$(createdByUserId);
|
||||
const isLoadingSignal = userProvider.isLoading$(createdByUserId);
|
||||
const name = computed(() => {
|
||||
const value = userSignal.value;
|
||||
if (!value) return I18n['Unknown User']();
|
||||
if (!value) {
|
||||
if (isLoadingSignal.value) {
|
||||
// if user info is loading
|
||||
return '';
|
||||
}
|
||||
return I18n['Unknown User']();
|
||||
}
|
||||
const removed = isRemovedUserInfo(value);
|
||||
if (removed) {
|
||||
return I18n['Deleted User']();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { PublicUserService } from '@affine/core/modules/cloud';
|
||||
import { UserFriendlyError } from '@affine/error';
|
||||
import { UserServiceExtension } from '@blocksuite/affine/shared/services';
|
||||
|
||||
export function patchUserExtensions(publicUserService: PublicUserService) {
|
||||
@@ -7,6 +8,20 @@ export function patchUserExtensions(publicUserService: PublicUserService) {
|
||||
userInfo$(id) {
|
||||
return publicUserService.publicUser$(id).signal;
|
||||
},
|
||||
// eslint-disable-next-line rxjs/finnish
|
||||
isLoading$(id) {
|
||||
return publicUserService.isLoading$(id).signal;
|
||||
},
|
||||
// eslint-disable-next-line rxjs/finnish
|
||||
error$(id) {
|
||||
return publicUserService.error$(id).selector(error => {
|
||||
if (error) {
|
||||
return UserFriendlyError.fromAny(error).name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}).signal;
|
||||
},
|
||||
revalidateUserInfo(id) {
|
||||
publicUserService.revalidate(id);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user