feat: add online status in user popover

pull/150/head
moonrailgun 2 years ago
parent 56c042ddd5
commit 1b813f9b82

@ -1,7 +1,7 @@
import { fetchImagePrimaryColor } from '@/utils/image-helper'; import { fetchImagePrimaryColor } from '@/utils/image-helper';
import React, { PropsWithChildren } from 'react'; import React, { PropsWithChildren } from 'react';
import { AvatarWithPreview, getTextColorHex } from 'tailchat-design'; import { AvatarWithPreview, getTextColorHex } from 'tailchat-design';
import { useAsync, UserBaseInfo } from 'tailchat-shared'; import { useAsync, useCachedOnlineStatus, UserBaseInfo } from 'tailchat-shared';
/** /**
* *
@ -10,6 +10,8 @@ export const UserProfileContainer: React.FC<
PropsWithChildren<{ userInfo: UserBaseInfo }> PropsWithChildren<{ userInfo: UserBaseInfo }>
> = React.memo((props) => { > = React.memo((props) => {
const { userInfo } = props; const { userInfo } = props;
const userId = userInfo._id;
const [isOnline] = useCachedOnlineStatus([userId]);
const { value: bannerColor } = useAsync(async () => { const { value: bannerColor } = useAsync(async () => {
if (!userInfo.avatar) { if (!userInfo.avatar) {
@ -35,6 +37,7 @@ export const UserProfileContainer: React.FC<
size={80} size={80}
src={userInfo.avatar} src={userInfo.avatar}
name={userInfo.nickname} name={userInfo.nickname}
isOnline={isOnline}
/> />
</div> </div>

@ -3,7 +3,6 @@ import {
prop, prop,
DocumentType, DocumentType,
Ref, Ref,
ReturnModelType,
index, index,
} from '@typegoose/typegoose'; } from '@typegoose/typegoose';
import type { Base } from '@typegoose/typegoose/lib/defaultClasses'; import type { Base } from '@typegoose/typegoose/lib/defaultClasses';

Loading…
Cancel
Save