fix: add invite button, voice join dedup, voice panel immediate render
This commit is contained in:
@@ -3,6 +3,7 @@ import { useServerStore } from '../stores/server.ts';
|
||||
import { useChannelStore } from '../stores/channel.ts';
|
||||
import { VoiceChannel } from './VoiceChannel.tsx';
|
||||
import { CreateChannelModal } from './CreateChannelModal.tsx';
|
||||
import { InviteModal } from './InviteModal.tsx';
|
||||
|
||||
export function ChannelList() {
|
||||
const activeServerId = useServerStore((state) => state.activeServerId);
|
||||
@@ -12,6 +13,7 @@ export function ChannelList() {
|
||||
const activeChannelId = useChannelStore((state) => state.activeChannelId);
|
||||
const setActiveChannel = useChannelStore((state) => state.setActiveChannel);
|
||||
const [showCreate, setShowCreate] = useState(false);
|
||||
const [showInvite, setShowInvite] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (activeServerId) {
|
||||
@@ -47,13 +49,22 @@ export function ChannelList() {
|
||||
<div className="terminal-border border-t-0 border-x-0 px-3 py-2 text-gb-fg truncate flex items-center justify-between">
|
||||
<span>{activeServerId ? `[SERVER ${activeServer?.name ?? activeServerId}]` : '[NO SERVER]'}</span>
|
||||
{activeServerId && (
|
||||
<button
|
||||
onClick={() => setShowCreate(true)}
|
||||
className="terminal-button text-xs"
|
||||
title="Create channel"
|
||||
>
|
||||
[+]
|
||||
</button>
|
||||
<div className="flex gap-1">
|
||||
<button
|
||||
onClick={() => setShowInvite(true)}
|
||||
className="terminal-button text-xs"
|
||||
title="Invite people"
|
||||
>
|
||||
[INV]
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setShowCreate(true)}
|
||||
className="terminal-button text-xs"
|
||||
title="Create channel"
|
||||
>
|
||||
[+]
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex-1 overflow-y-auto p-2 font-mono text-sm">
|
||||
@@ -90,6 +101,9 @@ export function ChannelList() {
|
||||
{showCreate && activeServerId && (
|
||||
<CreateChannelModal serverId={activeServerId} onClose={() => setShowCreate(false)} />
|
||||
)}
|
||||
{showInvite && activeServerId && activeServer && (
|
||||
<InviteModal serverId={activeServerId} serverName={activeServer.name} onClose={() => setShowInvite(false)} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,12 +15,20 @@ export function VoiceChannel({ channelId, channelName }: VoiceChannelProps) {
|
||||
|
||||
const handleClick = () => {
|
||||
if (!isActive) {
|
||||
joinVoice(channelId, channelName);
|
||||
console.log("[VoiceChannel] joining voice:", channelId, channelName);
|
||||
joinVoice(channelId, channelName).catch((err) => {
|
||||
console.error("[VoiceChannel] joinVoice failed:", err);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const error = useVoiceStore((state) => state.error);
|
||||
|
||||
return (
|
||||
<div className="mb-0.5">
|
||||
{error && (
|
||||
<div className="px-2 py-0.5 text-gb-red text-xxs">! {error}</div>
|
||||
)}
|
||||
<button
|
||||
onClick={handleClick}
|
||||
className={`w-full text-left px-2 py-1 rounded-sm flex items-center gap-2 ${
|
||||
|
||||
Reference in New Issue
Block a user