From 1b813f9b82e49b72db2ca155c03eb6565f2a22a6 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sat, 2 Sep 2023 22:40:22 +0800 Subject: [PATCH] feat: add online status in user popover --- client/web/src/components/UserProfileContainer.tsx | 5 ++++- server/models/chat/ack.ts | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/web/src/components/UserProfileContainer.tsx b/client/web/src/components/UserProfileContainer.tsx index bf7c1709..ac9ab216 100644 --- a/client/web/src/components/UserProfileContainer.tsx +++ b/client/web/src/components/UserProfileContainer.tsx @@ -1,7 +1,7 @@ import { fetchImagePrimaryColor } from '@/utils/image-helper'; import React, { PropsWithChildren } from 'react'; 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 }> > = React.memo((props) => { const { userInfo } = props; + const userId = userInfo._id; + const [isOnline] = useCachedOnlineStatus([userId]); const { value: bannerColor } = useAsync(async () => { if (!userInfo.avatar) { @@ -35,6 +37,7 @@ export const UserProfileContainer: React.FC< size={80} src={userInfo.avatar} name={userInfo.nickname} + isOnline={isOnline} /> diff --git a/server/models/chat/ack.ts b/server/models/chat/ack.ts index cf29ff57..2f2adc89 100644 --- a/server/models/chat/ack.ts +++ b/server/models/chat/ack.ts @@ -3,7 +3,6 @@ import { prop, DocumentType, Ref, - ReturnModelType, index, } from '@typegoose/typegoose'; import type { Base } from '@typegoose/typegoose/lib/defaultClasses';