mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
Rework layout to match the real TS3 client's structure
Adds a menu bar, an icon-based toolbar, and splits the right side into a channel/server info panel (topic, codec, password, client count) on top of the chat log - previously a single click switched channels, now that only selects/shows info while a double-click actually joins, like the native client. Required exposing a few more real protocol fields from tsclientlib (channel codec/topic/max clients/password, server name/max clients) that weren't surfaced before. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ec034d2d6b
commit
95a3761235
4 files changed
+349
-80
No files matched your search
+19
-5
@@ -15,8 +15,8 @@ use tsclientlib::events::Event as BookEvent;
|
|||||||
use tsclientlib::messages::c2s::{OutClientPokeRequestPart, OutSendTextMessagePart};
|
use tsclientlib::messages::c2s::{OutClientPokeRequestPart, OutSendTextMessagePart};
|
||||||
use tsclientlib::prelude::*;
|
use tsclientlib::prelude::*;
|
||||||
use tsclientlib::{
|
use tsclientlib::{
|
||||||
data, ChannelId, ClientId, Connection, DisconnectOptions, MessageHandle, MessageTarget,
|
data, ChannelId, ClientId, Connection, DisconnectOptions, MaxClients, MessageHandle,
|
||||||
StreamItem, TextMessageTargetMode,
|
MessageTarget, StreamItem, TextMessageTargetMode,
|
||||||
};
|
};
|
||||||
use tsproto_packets::packets::{AudioData, CodecType, OutAudio};
|
use tsproto_packets::packets::{AudioData, CodecType, OutAudio};
|
||||||
|
|
||||||
@@ -47,6 +47,10 @@ struct ChannelInfo {
|
|||||||
parent: u64,
|
parent: u64,
|
||||||
order: u64,
|
order: u64,
|
||||||
name: String,
|
name: String,
|
||||||
|
topic: String,
|
||||||
|
codec: String,
|
||||||
|
max_clients: Option<u16>,
|
||||||
|
has_password: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
@@ -65,7 +69,7 @@ struct ClientInfo {
|
|||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
enum Event {
|
enum Event {
|
||||||
#[serde(rename = "connected")]
|
#[serde(rename = "connected")]
|
||||||
Connected { welcome_message: String },
|
Connected { welcome_message: String, server_name: String, server_max_clients: u16 },
|
||||||
#[serde(rename = "channels")]
|
#[serde(rename = "channels")]
|
||||||
Channels { channels: Vec<ChannelInfo>, clients: Vec<ClientInfo> },
|
Channels { channels: Vec<ChannelInfo>, clients: Vec<ClientInfo> },
|
||||||
#[serde(rename = "chatMessage")]
|
#[serde(rename = "chatMessage")]
|
||||||
@@ -144,6 +148,13 @@ fn snapshot(con: &data::Connection) -> Event {
|
|||||||
parent: ch.parent.0,
|
parent: ch.parent.0,
|
||||||
order: *order.get(&ch.id.0).unwrap_or(&0),
|
order: *order.get(&ch.id.0).unwrap_or(&0),
|
||||||
name: ch.name.clone(),
|
name: ch.name.clone(),
|
||||||
|
topic: ch.topic.clone().unwrap_or_default(),
|
||||||
|
codec: format!("{:?}", ch.codec),
|
||||||
|
max_clients: match ch.max_clients {
|
||||||
|
Some(MaxClients::Limited(n)) => Some(n),
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
has_password: ch.has_password.unwrap_or(false),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let clients = con
|
let clients = con
|
||||||
@@ -227,8 +238,11 @@ async fn run(args: Args) -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let welcome_message = con.get_state()?.server.welcome_message.clone();
|
let server_state = con.get_state()?;
|
||||||
emit(&Event::Connected { welcome_message });
|
let welcome_message = server_state.server.welcome_message.clone();
|
||||||
|
let server_name = server_state.server.name.clone();
|
||||||
|
let server_max_clients = server_state.server.max_clients;
|
||||||
|
emit(&Event::Connected { welcome_message, server_name, server_max_clients });
|
||||||
|
|
||||||
// Subscribe to all channels so we actually receive the full channel/client list.
|
// Subscribe to all channels so we actually receive the full channel/client list.
|
||||||
con.get_state()?.server.set_subscribed(true).send(&mut con)?;
|
con.get_state()?.server.set_subscribed(true).send(&mut con)?;
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ export interface ChannelInfo {
|
|||||||
parent: number;
|
parent: number;
|
||||||
order: number;
|
order: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
topic: string;
|
||||||
|
codec: string;
|
||||||
|
maxClients: number | null;
|
||||||
|
hasPassword: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ClientInfo {
|
export interface ClientInfo {
|
||||||
@@ -29,7 +33,7 @@ export interface ClientInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type Ts3ConnectionEvent =
|
export type Ts3ConnectionEvent =
|
||||||
| { type: "connected"; welcomeMessage: string }
|
| { type: "connected"; welcomeMessage: string; serverName: string; serverMaxClients: number }
|
||||||
| { type: "channels"; channels: ChannelInfo[]; clients: ClientInfo[] }
|
| { type: "channels"; channels: ChannelInfo[]; clients: ClientInfo[] }
|
||||||
| { type: "chatMessage"; from: string; message: string }
|
| { type: "chatMessage"; from: string; message: string }
|
||||||
| { type: "serverMessage"; from: string; message: string }
|
| { type: "serverMessage"; from: string; message: string }
|
||||||
@@ -87,9 +91,20 @@ export class Ts3Connection {
|
|||||||
is_channel_commander: boolean;
|
is_channel_commander: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface RawChannelInfo {
|
||||||
|
id: number;
|
||||||
|
parent: number;
|
||||||
|
order: number;
|
||||||
|
name: string;
|
||||||
|
topic: string;
|
||||||
|
codec: string;
|
||||||
|
max_clients: number | null;
|
||||||
|
has_password: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
const event = JSON.parse(line) as
|
const event = JSON.parse(line) as
|
||||||
| { type: "connected"; welcome_message: string }
|
| { type: "connected"; welcome_message: string; server_name: string; server_max_clients: number }
|
||||||
| { type: "channels"; channels: ChannelInfo[]; clients: RawClientInfo[] }
|
| { type: "channels"; channels: RawChannelInfo[]; clients: RawClientInfo[] }
|
||||||
| { type: "chatMessage"; from: string; message: string }
|
| { type: "chatMessage"; from: string; message: string }
|
||||||
| { type: "serverMessage"; from: string; message: string }
|
| { type: "serverMessage"; from: string; message: string }
|
||||||
| { type: "privateMessage"; partner_id: number; partner_name: string; from_self: boolean; message: string }
|
| { type: "privateMessage"; partner_id: number; partner_name: string; from_self: boolean; message: string }
|
||||||
@@ -100,11 +115,25 @@ export class Ts3Connection {
|
|||||||
| { type: "error"; message: string };
|
| { type: "error"; message: string };
|
||||||
|
|
||||||
if (event.type === "connected") {
|
if (event.type === "connected") {
|
||||||
this.emit({ type: "connected", welcomeMessage: event.welcome_message });
|
this.emit({
|
||||||
|
type: "connected",
|
||||||
|
welcomeMessage: event.welcome_message,
|
||||||
|
serverName: event.server_name,
|
||||||
|
serverMaxClients: event.server_max_clients,
|
||||||
|
});
|
||||||
} else if (event.type === "channels") {
|
} else if (event.type === "channels") {
|
||||||
this.emit({
|
this.emit({
|
||||||
type: "channels",
|
type: "channels",
|
||||||
channels: event.channels,
|
channels: event.channels.map((ch) => ({
|
||||||
|
id: ch.id,
|
||||||
|
parent: ch.parent,
|
||||||
|
order: ch.order,
|
||||||
|
name: ch.name,
|
||||||
|
topic: ch.topic,
|
||||||
|
codec: ch.codec,
|
||||||
|
maxClients: ch.max_clients,
|
||||||
|
hasPassword: ch.has_password,
|
||||||
|
})),
|
||||||
clients: event.clients.map((c) => ({
|
clients: event.clients.map((c) => ({
|
||||||
id: c.id,
|
id: c.id,
|
||||||
channel: c.channel,
|
channel: c.channel,
|
||||||
|
|||||||
+111
-7
@@ -54,19 +54,92 @@
|
|||||||
|
|
||||||
/* Toolbar */
|
/* Toolbar */
|
||||||
|
|
||||||
.ts-toolbar {
|
.ts-menubar {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1.5rem;
|
gap: 1.1rem;
|
||||||
|
padding: 0.25rem 0.75rem;
|
||||||
|
background: var(--bg-toolbar-1);
|
||||||
|
border-bottom: 1px solid var(--border-soft);
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-menubar-item {
|
||||||
|
color: var(--text-muted);
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-toolbar {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.4rem;
|
||||||
padding: 0.4rem 0.75rem;
|
padding: 0.4rem 0.75rem;
|
||||||
background: linear-gradient(to bottom, var(--bg-toolbar-1), var(--bg-toolbar-2));
|
background: linear-gradient(to bottom, var(--bg-toolbar-1), var(--bg-toolbar-2));
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ts-toolbar-icons {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-icon-button {
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 3px;
|
||||||
|
background: linear-gradient(to bottom, var(--button-bg-1), var(--button-bg-2));
|
||||||
|
color: var(--text);
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-icon-button:hover {
|
||||||
|
background: linear-gradient(to bottom, var(--button-bg-hover-1), var(--button-bg-hover-2));
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-icon-button:disabled {
|
||||||
|
opacity: 0.4;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-toolbar-sep {
|
||||||
|
width: 1px;
|
||||||
|
align-self: stretch;
|
||||||
|
background: var(--border);
|
||||||
|
margin: 0 0.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-icon-slider,
|
||||||
|
.ts-icon-select {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.3rem;
|
||||||
|
color: var(--text);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-icon-slider input[type="range"] {
|
||||||
|
width: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-icon-select select {
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: 0.1rem 0.3rem;
|
||||||
|
font-size: 12px;
|
||||||
|
background: var(--input-bg);
|
||||||
|
color: var(--input-text);
|
||||||
|
max-width: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
.ts-app-title {
|
.ts-app-title {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--accent);
|
color: var(--accent);
|
||||||
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ts-toolbar-fields {
|
.ts-toolbar-fields {
|
||||||
@@ -127,11 +200,6 @@
|
|||||||
background: linear-gradient(to bottom, var(--button-bg-hover-1), var(--button-bg-hover-2));
|
background: linear-gradient(to bottom, var(--button-bg-hover-1), var(--button-bg-hover-2));
|
||||||
}
|
}
|
||||||
|
|
||||||
.ts-theme-toggle {
|
|
||||||
padding: 0.2rem 0.5rem !important;
|
|
||||||
margin-left: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Body / tree */
|
/* Body / tree */
|
||||||
|
|
||||||
.ts-body {
|
.ts-body {
|
||||||
@@ -149,6 +217,42 @@
|
|||||||
border-right: 1px solid var(--border-soft);
|
border-right: 1px solid var(--border-soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ts-main-panel {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-info-panel {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 0.6rem 0.9rem;
|
||||||
|
border-bottom: 1px solid var(--border-soft);
|
||||||
|
background: var(--bg-toolbar-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-info-title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.4rem;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--accent);
|
||||||
|
margin-bottom: 0.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-info-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.4rem;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ts-row-selected {
|
||||||
|
background: var(--row-hover);
|
||||||
|
outline: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
.ts-tree-empty {
|
.ts-tree-empty {
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
|
|||||||
+185
-63
@@ -21,8 +21,14 @@ interface ChannelInfo {
|
|||||||
parent: number;
|
parent: number;
|
||||||
order: number;
|
order: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
topic: string;
|
||||||
|
codec: string;
|
||||||
|
maxClients: number | null;
|
||||||
|
hasPassword: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SelectedItem = { type: "server" } | { type: "channel"; id: number };
|
||||||
|
|
||||||
interface ClientInfo {
|
interface ClientInfo {
|
||||||
id: number;
|
id: number;
|
||||||
channel: number;
|
channel: number;
|
||||||
@@ -85,7 +91,9 @@ function ChannelTree({
|
|||||||
parent,
|
parent,
|
||||||
ownClientId,
|
ownClientId,
|
||||||
talkers,
|
talkers,
|
||||||
onSelectChannel,
|
selected,
|
||||||
|
onSelectItem,
|
||||||
|
onSwitchChannel,
|
||||||
onOpenPrivateChat,
|
onOpenPrivateChat,
|
||||||
onPokeClient,
|
onPokeClient,
|
||||||
}: {
|
}: {
|
||||||
@@ -94,7 +102,9 @@ function ChannelTree({
|
|||||||
parent: number;
|
parent: number;
|
||||||
ownClientId: number | null;
|
ownClientId: number | null;
|
||||||
talkers: Set<number>;
|
talkers: Set<number>;
|
||||||
onSelectChannel: (channelId: number) => void;
|
selected: SelectedItem | null;
|
||||||
|
onSelectItem: (item: SelectedItem) => void;
|
||||||
|
onSwitchChannel: (channelId: number) => void;
|
||||||
onOpenPrivateChat: (clientId: number, clientName: string) => void;
|
onOpenPrivateChat: (clientId: number, clientName: string) => void;
|
||||||
onPokeClient: (clientId: number, clientName: string) => void;
|
onPokeClient: (clientId: number, clientName: string) => void;
|
||||||
}) {
|
}) {
|
||||||
@@ -105,9 +115,17 @@ function ChannelTree({
|
|||||||
<ul className="ts-tree-list">
|
<ul className="ts-tree-list">
|
||||||
{children.map((channel) => (
|
{children.map((channel) => (
|
||||||
<li key={channel.id}>
|
<li key={channel.id}>
|
||||||
<div className="ts-row ts-channel-row" onClick={() => onSelectChannel(channel.id)}>
|
<div
|
||||||
|
className={`ts-row ts-channel-row${
|
||||||
|
selected?.type === "channel" && selected.id === channel.id ? " ts-row-selected" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => onSelectItem({ type: "channel", id: channel.id })}
|
||||||
|
onDoubleClick={() => onSwitchChannel(channel.id)}
|
||||||
|
title="Click to select, double-click to join"
|
||||||
|
>
|
||||||
<ChannelIcon />
|
<ChannelIcon />
|
||||||
<span>{channel.name}</span>
|
<span>{channel.name}</span>
|
||||||
|
{channel.hasPassword && <span title="Password protected">🔒</span>}
|
||||||
</div>
|
</div>
|
||||||
<ul className="ts-tree-list">
|
<ul className="ts-tree-list">
|
||||||
{clients
|
{clients
|
||||||
@@ -146,7 +164,9 @@ function ChannelTree({
|
|||||||
parent={channel.id}
|
parent={channel.id}
|
||||||
ownClientId={ownClientId}
|
ownClientId={ownClientId}
|
||||||
talkers={talkers}
|
talkers={talkers}
|
||||||
onSelectChannel={onSelectChannel}
|
selected={selected}
|
||||||
|
onSelectItem={onSelectItem}
|
||||||
|
onSwitchChannel={onSwitchChannel}
|
||||||
onOpenPrivateChat={onOpenPrivateChat}
|
onOpenPrivateChat={onOpenPrivateChat}
|
||||||
onPokeClient={onPokeClient}
|
onPokeClient={onPokeClient}
|
||||||
/>
|
/>
|
||||||
@@ -156,6 +176,65 @@ function ChannelTree({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function InfoPanel({
|
||||||
|
selected,
|
||||||
|
host,
|
||||||
|
serverName,
|
||||||
|
serverMaxClients,
|
||||||
|
totalClientCount,
|
||||||
|
channels,
|
||||||
|
clients,
|
||||||
|
}: {
|
||||||
|
selected: SelectedItem | null;
|
||||||
|
host: string;
|
||||||
|
serverName: string;
|
||||||
|
serverMaxClients: number;
|
||||||
|
totalClientCount: number;
|
||||||
|
channels: ChannelInfo[];
|
||||||
|
clients: ClientInfo[];
|
||||||
|
}) {
|
||||||
|
if (!selected || selected.type === "server") {
|
||||||
|
return (
|
||||||
|
<div className="ts-info-panel">
|
||||||
|
<div className="ts-info-title">
|
||||||
|
<ServerIcon />
|
||||||
|
<span>{serverName || host}</span>
|
||||||
|
</div>
|
||||||
|
<div className="ts-info-row">
|
||||||
|
<span>Clients:</span> <span>{totalClientCount} / {serverMaxClients || "∞"}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const channel = channels.find((c) => c.id === selected.id);
|
||||||
|
if (!channel) return <div className="ts-info-panel" />;
|
||||||
|
const clientCount = clients.filter((c) => c.channel === channel.id).length;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="ts-info-panel">
|
||||||
|
<div className="ts-info-title">
|
||||||
|
<ChannelIcon />
|
||||||
|
<span>{channel.name}</span>
|
||||||
|
</div>
|
||||||
|
{channel.topic && (
|
||||||
|
<div className="ts-info-row">
|
||||||
|
<span>Topic:</span> <span>{channel.topic}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="ts-info-row">
|
||||||
|
<span>Audio Codec:</span> <span>{channel.codec}</span>
|
||||||
|
</div>
|
||||||
|
<div className="ts-info-row">
|
||||||
|
<span>Password protected:</span> <span>{channel.hasPassword ? "Yes" : "No"}</span>
|
||||||
|
</div>
|
||||||
|
<div className="ts-info-row">
|
||||||
|
<span>Clients:</span> <span>{clientCount} / {channel.maxClients ?? "∞"}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
interface ChatEntry {
|
interface ChatEntry {
|
||||||
from: string;
|
from: string;
|
||||||
message: string;
|
message: string;
|
||||||
@@ -193,6 +272,9 @@ function App() {
|
|||||||
const [connectError, setConnectError] = useState<string | null>(null);
|
const [connectError, setConnectError] = useState<string | null>(null);
|
||||||
const [channels, setChannels] = useState<ChannelInfo[]>([]);
|
const [channels, setChannels] = useState<ChannelInfo[]>([]);
|
||||||
const [clients, setClients] = useState<ClientInfo[]>([]);
|
const [clients, setClients] = useState<ClientInfo[]>([]);
|
||||||
|
const [serverName, setServerName] = useState("");
|
||||||
|
const [serverMaxClients, setServerMaxClients] = useState(0);
|
||||||
|
const [selected, setSelected] = useState<SelectedItem | null>(null);
|
||||||
const [chat, setChat] = useState<ChatEntry[]>([]);
|
const [chat, setChat] = useState<ChatEntry[]>([]);
|
||||||
const [serverChat, setServerChat] = useState<ChatEntry[]>([]);
|
const [serverChat, setServerChat] = useState<ChatEntry[]>([]);
|
||||||
const [chatInput, setChatInput] = useState("");
|
const [chatInput, setChatInput] = useState("");
|
||||||
@@ -300,6 +382,9 @@ function App() {
|
|||||||
setConnected(true);
|
setConnected(true);
|
||||||
localStorage.setItem(LAST_HOST_KEY, host);
|
localStorage.setItem(LAST_HOST_KEY, host);
|
||||||
localStorage.setItem(LAST_NICKNAME_KEY, nickname);
|
localStorage.setItem(LAST_NICKNAME_KEY, nickname);
|
||||||
|
setServerName(data.serverName);
|
||||||
|
setServerMaxClients(data.serverMaxClients);
|
||||||
|
setSelected({ type: "server" });
|
||||||
setServerChat((prev) => [...prev, { from: "Server", message: data.welcomeMessage }]);
|
setServerChat((prev) => [...prev, { from: "Server", message: data.welcomeMessage }]);
|
||||||
break;
|
break;
|
||||||
case "channels":
|
case "channels":
|
||||||
@@ -350,6 +435,7 @@ function App() {
|
|||||||
setConnected(false);
|
setConnected(false);
|
||||||
setChannels([]);
|
setChannels([]);
|
||||||
setClients([]);
|
setClients([]);
|
||||||
|
setSelected(null);
|
||||||
setChat([]);
|
setChat([]);
|
||||||
setServerChat([]);
|
setServerChat([]);
|
||||||
setPmThreads({});
|
setPmThreads({});
|
||||||
@@ -432,10 +518,12 @@ function App() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSelectChannel = (channelId: number) => {
|
const handleSwitchChannel = (channelId: number) => {
|
||||||
socketRef.current?.send(JSON.stringify({ type: "switchChannel", channelId }));
|
socketRef.current?.send(JSON.stringify({ type: "switchChannel", channelId }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSelectItem = (item: SelectedItem) => setSelected(item);
|
||||||
|
|
||||||
const handleSendChat = () => {
|
const handleSendChat = () => {
|
||||||
const message = chatInput.trim();
|
const message = chatInput.trim();
|
||||||
if (!message) return;
|
if (!message) return;
|
||||||
@@ -486,69 +574,40 @@ function App() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`ts-app ts-theme-${theme}`}>
|
<div className={`ts-app ts-theme-${theme}`}>
|
||||||
|
<div className="ts-menubar">
|
||||||
|
{["Verbindungen", "Favoriten", "Selbst", "Rechte", "Extras", "Hilfe"].map((item) => (
|
||||||
|
<span key={item} className="ts-menubar-item">
|
||||||
|
{item}
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="ts-toolbar">
|
<div className="ts-toolbar">
|
||||||
<span className="ts-app-title">TS Web Client</span>
|
<div className="ts-toolbar-icons">
|
||||||
<div className="ts-toolbar-fields">
|
|
||||||
<label>
|
|
||||||
Server
|
|
||||||
<input value={host} onChange={(e) => setHost(e.target.value)} disabled={connected || connecting} />
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
Nickname
|
|
||||||
<input
|
|
||||||
value={nickname}
|
|
||||||
onChange={(e) => setNickname(e.target.value)}
|
|
||||||
disabled={connected || connecting}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
{!connected && (
|
|
||||||
<button
|
|
||||||
className={showPasswordFields ? "ts-mic-on" : undefined}
|
|
||||||
onClick={() => setShowPasswordFields((v) => !v)}
|
|
||||||
disabled={connecting}
|
|
||||||
title="Server/channel password"
|
|
||||||
>
|
|
||||||
🔒
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
{!connected && showPasswordFields && (
|
|
||||||
<>
|
|
||||||
<label>
|
|
||||||
Server password
|
|
||||||
<input
|
|
||||||
type="password"
|
|
||||||
value={serverPassword}
|
|
||||||
onChange={(e) => setServerPassword(e.target.value)}
|
|
||||||
disabled={connecting}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
Channel password
|
|
||||||
<input
|
|
||||||
type="password"
|
|
||||||
value={channelPassword}
|
|
||||||
onChange={(e) => setChannelPassword(e.target.value)}
|
|
||||||
disabled={connecting}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{!connected ? (
|
{!connected ? (
|
||||||
<button onClick={handleConnect} disabled={connecting}>
|
<button
|
||||||
{connecting ? "Connecting…" : "Connect"}
|
className="ts-icon-button"
|
||||||
|
onClick={handleConnect}
|
||||||
|
disabled={connecting}
|
||||||
|
title={connecting ? "Connecting…" : "Connect"}
|
||||||
|
>
|
||||||
|
🟢
|
||||||
</button>
|
</button>
|
||||||
) : (
|
) : (
|
||||||
<button onClick={handleDisconnect}>Disconnect</button>
|
<button className="ts-icon-button" onClick={handleDisconnect} title="Disconnect">
|
||||||
|
🔴
|
||||||
|
</button>
|
||||||
)}
|
)}
|
||||||
|
<span className="ts-toolbar-sep" />
|
||||||
<button
|
<button
|
||||||
className={micOn ? "ts-mic-on" : undefined}
|
className={`ts-icon-button${micOn ? " ts-mic-on" : ""}`}
|
||||||
onClick={handleToggleMic}
|
onClick={handleToggleMic}
|
||||||
disabled={!connected}
|
disabled={!connected}
|
||||||
title={micOn ? "Voice activation on - click to mute" : "Enable microphone (voice activation)"}
|
title={micOn ? "Voice activation on - click to mute" : "Enable microphone (voice activation)"}
|
||||||
>
|
>
|
||||||
{micOn ? "🎤" : "🔇"}
|
{micOn ? "🎤" : "🔇"}
|
||||||
</button>
|
</button>
|
||||||
<label title="Voice activation sensitivity">
|
<label className="ts-icon-slider" title="Voice activation sensitivity">
|
||||||
🎚️
|
🎚️
|
||||||
<input
|
<input
|
||||||
type="range"
|
type="range"
|
||||||
@@ -560,11 +619,11 @@ function App() {
|
|||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
{hasNativeOutputPicker() ? (
|
{hasNativeOutputPicker() ? (
|
||||||
<button onClick={handlePickOutputDevice} title="Choose output device">
|
<button className="ts-icon-button" onClick={handlePickOutputDevice} title="Choose output device">
|
||||||
🔊 {outputDeviceLabel}
|
🔊
|
||||||
</button>
|
</button>
|
||||||
) : (
|
) : (
|
||||||
<label>
|
<label className="ts-icon-select">
|
||||||
🔊
|
🔊
|
||||||
<select
|
<select
|
||||||
value={outputDeviceId}
|
value={outputDeviceId}
|
||||||
@@ -580,14 +639,59 @@ function App() {
|
|||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
|
<span className="ts-toolbar-sep" />
|
||||||
<button
|
<button
|
||||||
className="ts-theme-toggle"
|
className="ts-icon-button"
|
||||||
onClick={() => setTheme((t) => (t === "dark" ? "light" : "dark"))}
|
onClick={() => setTheme((t) => (t === "dark" ? "light" : "dark"))}
|
||||||
title="Toggle theme"
|
title="Toggle theme"
|
||||||
>
|
>
|
||||||
{theme === "dark" ? "☀️" : "🌙"}
|
{theme === "dark" ? "☀️" : "🌙"}
|
||||||
</button>
|
</button>
|
||||||
|
<span className="ts-app-title">TS Web Client</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{!connected && (
|
||||||
|
<div className="ts-toolbar-fields">
|
||||||
|
<label>
|
||||||
|
Server
|
||||||
|
<input value={host} onChange={(e) => setHost(e.target.value)} disabled={connecting} />
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Nickname
|
||||||
|
<input value={nickname} onChange={(e) => setNickname(e.target.value)} disabled={connecting} />
|
||||||
|
</label>
|
||||||
|
<button
|
||||||
|
className={showPasswordFields ? "ts-mic-on" : undefined}
|
||||||
|
onClick={() => setShowPasswordFields((v) => !v)}
|
||||||
|
disabled={connecting}
|
||||||
|
title="Server/channel password"
|
||||||
|
>
|
||||||
|
🔒
|
||||||
|
</button>
|
||||||
|
{showPasswordFields && (
|
||||||
|
<>
|
||||||
|
<label>
|
||||||
|
Server password
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
value={serverPassword}
|
||||||
|
onChange={(e) => setServerPassword(e.target.value)}
|
||||||
|
disabled={connecting}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Channel password
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
value={channelPassword}
|
||||||
|
onChange={(e) => setChannelPassword(e.target.value)}
|
||||||
|
disabled={connecting}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{connectError && (
|
{connectError && (
|
||||||
@@ -636,9 +740,12 @@ function App() {
|
|||||||
<div className="ts-tree-panel">
|
<div className="ts-tree-panel">
|
||||||
{connected ? (
|
{connected ? (
|
||||||
<>
|
<>
|
||||||
<div className="ts-row ts-server-row">
|
<div
|
||||||
|
className={`ts-row ts-server-row${selected?.type === "server" ? " ts-row-selected" : ""}`}
|
||||||
|
onClick={() => handleSelectItem({ type: "server" })}
|
||||||
|
>
|
||||||
<ServerIcon />
|
<ServerIcon />
|
||||||
<span>{host}</span>
|
<span>{serverName || host}</span>
|
||||||
</div>
|
</div>
|
||||||
<ChannelTree
|
<ChannelTree
|
||||||
channels={channels}
|
channels={channels}
|
||||||
@@ -646,7 +753,9 @@ function App() {
|
|||||||
parent={0}
|
parent={0}
|
||||||
ownClientId={ownClient?.id ?? null}
|
ownClientId={ownClient?.id ?? null}
|
||||||
talkers={displayTalkers}
|
talkers={displayTalkers}
|
||||||
onSelectChannel={handleSelectChannel}
|
selected={selected}
|
||||||
|
onSelectItem={handleSelectItem}
|
||||||
|
onSwitchChannel={handleSwitchChannel}
|
||||||
onOpenPrivateChat={handleOpenPrivateChat}
|
onOpenPrivateChat={handleOpenPrivateChat}
|
||||||
onPokeClient={handlePokeClient}
|
onPokeClient={handlePokeClient}
|
||||||
/>
|
/>
|
||||||
@@ -656,6 +765,18 @@ function App() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="ts-main-panel">
|
||||||
|
{connected && (
|
||||||
|
<InfoPanel
|
||||||
|
selected={selected}
|
||||||
|
host={host}
|
||||||
|
serverName={serverName}
|
||||||
|
serverMaxClients={serverMaxClients}
|
||||||
|
totalClientCount={clients.length}
|
||||||
|
channels={channels}
|
||||||
|
clients={clients}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className="ts-chat-panel">
|
<div className="ts-chat-panel">
|
||||||
<div className="ts-chat-tabs">
|
<div className="ts-chat-tabs">
|
||||||
<button
|
<button
|
||||||
@@ -735,6 +856,7 @@ function App() {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="ts-log">
|
<div className="ts-log">
|
||||||
|
|||||||
Reference in new issue
Block a user