-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(web): currentConf minimized card controller
- Loading branch information
Showing
6 changed files
with
161 additions
and
5 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
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,17 @@ | ||
"use client"; | ||
|
||
import { useCurrentConfIdStore } from "@/stores/useCurentConfIdStore"; | ||
import React from "react"; | ||
import { MinimizedRoomCardController } from "./room/MinimizedRoomCardController"; | ||
|
||
export const RightBlock: React.FC = () => { | ||
const { currentConfId } = useCurrentConfIdStore(); | ||
|
||
return ( | ||
<div> | ||
{currentConfId ? ( | ||
<MinimizedRoomCardController confId={currentConfId} /> | ||
) : null} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { Button, Icon } from "@spek/ui"; | ||
|
||
interface MinimizedRoomCardProps { | ||
onFullScreenClick: () => void; | ||
leaveLoading?: boolean; | ||
room: { | ||
name: string; | ||
descriptioin: string; | ||
me: { | ||
isSpeaker: boolean; | ||
isMuted: boolean; | ||
isDeafened: boolean; | ||
switchMuted: () => void; | ||
switchDeafened: () => void; | ||
leave: () => void; | ||
}; | ||
}; | ||
} | ||
|
||
export const MinimizedRoomCard: React.FC<MinimizedRoomCardProps> = ({ | ||
onFullScreenClick, | ||
room, | ||
leaveLoading, | ||
}) => { | ||
return ( | ||
<div | ||
className="bg-primary-900 border border-accent rounded-lg p-4 gap-4 grid max-w-md w-full" | ||
data-testid="minimized-room-card" | ||
> | ||
<div className="gap-1 grid"> | ||
<h4 className="text-primary-100 break-all overflow-hidden"> | ||
{room.name} | ||
</h4> | ||
<p className="text-primary-300 overflow-ellipsis overflow-hidden w-auto"> | ||
{room.descriptioin} | ||
</p> | ||
</div> | ||
<div className="flex flex-row"> | ||
<div className="grid grid-cols-3 gap-2"> | ||
<div | ||
onClick={room.me.switchMuted} | ||
className={room.me.isMuted ? "cursor-pointer" : ""} | ||
> | ||
{room.me.isMuted ? <Icon name="mic-off" /> : <Icon name="mic" />} | ||
</div> | ||
|
||
<div | ||
onClick={room.me.switchDeafened} | ||
className={room.me.isDeafened ? "cursor-pointer" : ""} | ||
> | ||
{room.me.isDeafened ? ( | ||
<Icon name="volume-x" /> | ||
) : ( | ||
<Icon name="volume-2" /> | ||
)} | ||
</div> | ||
|
||
<div onClick={onFullScreenClick} className="cursor-pointer"> | ||
<Icon name="expand" /> | ||
</div> | ||
</div> | ||
<Button | ||
transition | ||
loading={leaveLoading} | ||
className="flex-grow ml-4" | ||
onClick={room.me.leave} | ||
color="destructive" | ||
> | ||
Leave | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
}; |
63 changes: 63 additions & 0 deletions
63
apps/web/src/components/room/MinimizedRoomCardController.tsx
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,63 @@ | ||
"use client"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
import { useConn } from "@/hooks/useConn"; | ||
import { MinimizedRoomCard } from "./MinimizedRoomCard"; | ||
import { useMuteStore } from "@/stores/useMuteStore"; | ||
import { useDeafStore } from "@/stores/useDeafStore"; | ||
import { useSetMute } from "@/hooks/useSetMute"; | ||
import { useSetDeafen } from "@/hooks/useSetDeafen"; | ||
import { useLeaveConf } from "@/hooks/useLeaveConf"; | ||
import { useTypeSafeQuery } from "@/hooks/useTypeSafeQuery"; | ||
|
||
interface Props { | ||
confId: string; | ||
} | ||
|
||
export const MinimizedRoomCardController: React.FC<Props> = ({ confId }) => { | ||
const { user } = useConn(); | ||
const { muted } = useMuteStore(); | ||
const { deafened } = useDeafStore(); | ||
const setMute = useSetMute(); | ||
const setDeafen = useSetDeafen(); | ||
const { isLoading, leaveConf } = useLeaveConf(); | ||
const { push } = useRouter(); | ||
const { isLoading: joinLoading, data } = useTypeSafeQuery( | ||
["joinConfAndGetInfo", confId], | ||
{}, | ||
[confId] | ||
); | ||
|
||
if (joinLoading || !data) { | ||
return null; | ||
} | ||
|
||
if ("error" in data) { | ||
return <div>{data.error}</div>; | ||
} | ||
|
||
return ( | ||
<> | ||
{user ? ( | ||
<div className="w-full"> | ||
<MinimizedRoomCard | ||
onFullScreenClick={() => push(`/conf/${data.conf.id}`)} | ||
leaveLoading={isLoading} | ||
room={{ | ||
me: { | ||
isDeafened: deafened, | ||
isMuted: muted, | ||
leave: () => leaveConf(), | ||
isSpeaker: true, | ||
switchDeafened: () => setDeafen(!deafened), | ||
switchMuted: () => setMute(!muted), | ||
}, | ||
name: data?.conf.name, | ||
descriptioin: data?.conf.description, | ||
}} | ||
/> | ||
</div> | ||
) : null} | ||
</> | ||
); | ||
}; |
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