-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19df891
commit 755ac38
Showing
7 changed files
with
115 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { users } from "@/dummy-data/db"; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
|
@@ -9,8 +8,16 @@ import { | |
} from "@/components/ui/dialog"; | ||
import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; | ||
import { Crown } from "lucide-react"; | ||
import { Conversation } from "@/store/chat-store"; | ||
import { useQuery } from "convex/react"; | ||
import { api } from "../../../convex/_generated/api"; | ||
|
||
const GroupMembersDialog = () => { | ||
type GroupMembersDialogProps = { | ||
selectedConversation: Conversation; | ||
}; | ||
|
||
const GroupMembersDialog = ({ selectedConversation }: GroupMembersDialogProps) => { | ||
const users = useQuery(api.users.getGroupMembers, { conversationId: selectedConversation._id }); | ||
return ( | ||
<Dialog> | ||
<DialogTrigger> | ||
|
@@ -39,7 +46,9 @@ const GroupMembersDialog = () => { | |
{/* [email protected] */} | ||
{user.name || user.email.split("@")[0]} | ||
</h3> | ||
{user.admin && <Crown size={16} className='text-yellow-400' />} | ||
{user._id === selectedConversation.admin && ( | ||
<Crown size={16} className='text-yellow-400' /> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Id } from "../../convex/_generated/dataModel"; | ||
import { create } from "zustand"; | ||
|
||
export type Conversation = { | ||
_id: Id<"conversations">; | ||
image?: string; | ||
participants: Id<"users">[]; | ||
isGroup: boolean; | ||
name?: string; | ||
groupImage?: string; | ||
groupName?: string; | ||
admin?: Id<"users">; | ||
isOnline?: boolean; | ||
lastMessage?: { | ||
_id: Id<"messages">; | ||
conversation: Id<"conversations">; | ||
content: string; | ||
sender: Id<"users">; | ||
}; | ||
}; | ||
|
||
type ConversationStore = { | ||
selectedConversation: Conversation | null; | ||
setSelectedConversation: (conversation: Conversation | null) => void; | ||
}; | ||
|
||
export const useConversationStore = create<ConversationStore>((set) => ({ | ||
selectedConversation: null, | ||
setSelectedConversation: (conversation) => set({ selectedConversation: conversation }), | ||
})); |