Skip to content

Commit b916f6d

Browse files
fix: member active status in server's chat
1 parent 8b1d781 commit b916f6d

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

components/chat/chat-header.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import MobileToggle from "@/components/mobile-toggle";
44
import SocketIndicator from "@/components/socket-indicator";
55
import { MemberWithProfile } from "@/types/server";
66
import { Profile } from "@prisma/client";
7-
import UserAvatarWraper from "../user-avatar-wrapper";
7+
import UserAvatarWrapper from "../user-avatar-wrapper";
88
import { ChatVideoButton } from "./chat-video-button";
99

1010
interface ChatHeaderProps {
@@ -36,10 +36,7 @@ const ChatHeader = ({
3636
<Hash className="w-5 h-5 text-zinc-500 dark:text-zinc-400 mr-2" />
3737
)}
3838
{type === "conversation" && (
39-
<UserAvatarWraper
40-
imageUrl={imageUrl || ""}
41-
profile={callee?.profile || ({} as Profile)}
42-
/>
39+
<UserAvatarWrapper profile={callee?.profile || ({} as Profile)} />
4340
)}
4441
<p className="font-semibold text-md text-black dark:text-white ml-2">
4542
{name}

components/chat/chat-item.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import { ActionTooltip } from "@/components/action-tooltip";
1414
import { Button } from "@/components/ui/button";
1515
import { Form, FormControl, FormField } from "@/components/ui/form";
1616
import { Input } from "@/components/ui/input";
17-
import UserAvatar from "@/components/user-avatar";
1817
import { useModal } from "@/hooks/use-modal-store";
1918
import { cn } from "@/utils/cn";
2019
import axios from "axios";
2120
import { useParams, useRouter } from "next/navigation";
21+
import UserAvatarWrapper from "../user-avatar-wrapper";
2222

2323
interface ChatItemProps {
2424
id: string;
@@ -134,7 +134,7 @@ const ChatItem = ({
134134
onClick={onMemberClick}
135135
className="cursor-pointer hover:drop-shadow-md transition"
136136
>
137-
<UserAvatar src={member.profile.imageUrl} />
137+
<UserAvatarWrapper profile={member.profile} />
138138
</div>
139139
<div className="flex flex-col w-full">
140140
<div className="flex items-center gap-x-2">

components/modals/members-modal.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
DialogTitle,
2222
} from "@/components/ui/dialog";
2323
import { ScrollArea } from "@/components/ui/scroll-area";
24-
import UserAvatar from "@/components/user-avatar";
2524
import { useModal } from "@/hooks/use-modal-store";
2625
import { ServerWithMembersWithProfiles } from "@/types/server";
2726

@@ -39,6 +38,7 @@ import {
3938
import { MemberRole } from "@prisma/client";
4039
import axios from "axios";
4140
import { useRouter } from "next/navigation";
41+
import UserAvatarWrapper from "../user-avatar-wrapper";
4242

4343
const roleIcons = {
4444
GUEST: null,
@@ -108,10 +108,7 @@ const MembersModal = () => {
108108
<ScrollArea className="mt-8 max-h-[420px] pr-6">
109109
{server?.members?.map((member) => (
110110
<div key={member?.id} className="flex items-center gap-x-2 mb-6">
111-
<UserAvatar
112-
src={member?.profile.imageUrl}
113-
isOnline={member?.profile?.isOnline}
114-
/>
111+
<UserAvatarWrapper profile={member?.profile} />
115112
<div className="flex flex-col gap-y-1">
116113
<div className="text-xs font-semibold items-center flex gap-x-1">
117114
{member?.profile.name}

components/user-avatar-wrapper.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import { useOnlineStatus } from "@/hooks/use-online-status";
44
import { Profile } from "@prisma/client";
55
import UserAvatar from "./user-avatar";
66

7-
interface UserAvatarWraperProps {
8-
imageUrl: string;
7+
interface UserAvatarWrapperProps {
98
profile: Profile;
109
}
1110

12-
const UserAvatarWraper = ({ imageUrl, profile }: UserAvatarWraperProps) => {
11+
const UserAvatarWrapper = ({ profile }: UserAvatarWrapperProps) => {
1312
const { isUserOnline } = useOnlineStatus(profile || ({} as Profile));
1413

15-
return <UserAvatar src={imageUrl} isOnline={isUserOnline} />;
14+
return <UserAvatar src={profile?.imageUrl} isOnline={isUserOnline} />;
1615
};
1716

18-
export default UserAvatarWraper;
17+
export default UserAvatarWrapper;

0 commit comments

Comments
 (0)