Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
MrQuackDuck committed Dec 14, 2024
1 parent 380936d commit 39ef90e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/shared/lib/emojis.json
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@
"value": "👍",
"name": "thumbs up :thumbsup:"
},
{
"value": "🤝",
"name": "handshake :handshake:"
},
{
"value": "🙏",
"name": "folded hands :pray:"
Expand Down
10 changes: 5 additions & 5 deletions src/widgets/voice-chat-section/ui/VoiceChat.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Button } from "@/shared/ui/Button";
import { Collapsible, CollapsibleContent } from "@/shared/ui/Collapsible";
import { ChevronUpIcon, Plug2Icon, UnplugIcon, Volume2Icon } from "lucide-react";
import { useState } from "react";
import { VoiceChatConnection } from "../model/VoiceChatConnection";
import { cn } from "@/shared/lib/utils";
import { useContextSelector } from "use-context-selector";
Expand All @@ -16,14 +15,15 @@ interface VoiceChatProps {
joinVoiceChat: (voiceChatConnection: VoiceChatConnection) => void;
leaveVoiceChat: (voiceChatConnection: VoiceChatConnection) => void;
currentlyTalkingUsers?: CurrentlyTalkingUser[];
isCollapsed: boolean;
toggleCollapse: () => void;
}

function VoiceChat(props: VoiceChatProps) {
const [isCollapsed, setIsCollapsed] = useState(false);
const users = useContextSelector(UsersContext, (c) => c.users);

function toggleCollapse() {
setIsCollapsed(!isCollapsed);
props.toggleCollapse();
}

function joinVoiceChat() {
Expand Down Expand Up @@ -51,10 +51,10 @@ function VoiceChat(props: VoiceChatProps) {
</span>
</Button>
<Button onClick={toggleCollapse} className="w-8 h-8 flex-shrink-0 ml-1" variant="ghost" size="icon">
<ChevronUpIcon className={cn("w-5 h-5 text-slate-400 transition-transform duration-100", isCollapsed && "rotate-180")} />
<ChevronUpIcon className={cn("w-5 h-5 text-slate-400 transition-transform duration-100", props.isCollapsed && "rotate-180")} />
</Button>
</div>
<Collapsible open={!isCollapsed} onOpenChange={setIsCollapsed}>
<Collapsible open={!props.isCollapsed}>
<CollapsibleContent asChild>
<div className="flex flex-col pt-1">
{props.voiceChatConnection.joinedUsers.map((user) => (
Expand Down
12 changes: 12 additions & 0 deletions src/widgets/voice-chat-section/ui/VoiceChatSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,14 @@ function VoiceChatSection() {
}
}, [voiceInputDevice]);

// Collapsed voice channels (id is the room guid)
let [collapsedVoiceChannels, setCollapsedVoiceChannels] = useState<string[]>([]);

let toggleCollapseVoiceChannel = (roomGuid: string) => {
if (collapsedVoiceChannels.includes(roomGuid)) setCollapsedVoiceChannels(collapsedVoiceChannels.filter((id) => id != roomGuid));
else setCollapsedVoiceChannels([...collapsedVoiceChannels, roomGuid]);
};

return (
<div className="flex flex-col h-full gap-2 pt-1.5">
{joinedVoiceConnection && (
Expand All @@ -363,6 +371,8 @@ function VoiceChatSection() {
leaveVoiceChat={leaveVoiceChat}
currentlyTalkingUsers={currentlyTalkingUsers}
roomName={joinedRooms.find((r) => r.guid == joinedVoiceConnection.roomGuid)?.name!}
isCollapsed={collapsedVoiceChannels.includes(joinedVoiceConnection.roomGuid)}
toggleCollapse={() => toggleCollapseVoiceChannel(joinedVoiceConnection.roomGuid)}
/>
)}

Expand All @@ -373,6 +383,8 @@ function VoiceChatSection() {
joinVoiceChat={joinVoiceChat}
leaveVoiceChat={leaveVoiceChat}
roomName={selectedRoom.name}
isCollapsed={collapsedVoiceChannels.includes(selectedRoomVoiceChat.roomGuid)}
toggleCollapse={() => toggleCollapseVoiceChannel(selectedRoomVoiceChat.roomGuid)}
/>
)}

Expand Down

0 comments on commit 39ef90e

Please sign in to comment.