mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Fix talking indicator: also respect missing talk power in moderated channels
The previous fix only accounted for the local mute toggle. In a moderated channel (one with a talk power requirement) a client without sufficient talk power still has selfActive/VAD firing locally and no local concept of whether they're actually allowed to transmit, so the indicator stayed on regardless. The connector now computes has_talk_power per client from the book state (talk_power_granted || talk_power >= channel.needed_talk_power), mirroring tsclientlib's own internal intern_can_send_audio moderated-channel check, and threads it through gateway and frontend. The talking indicator (both the own-client injection into displayTalkers and the general per-client render in ChannelTree) now requires hasTalkPower too.
This commit is contained in:
1 parent
4847972c80
commit
6e343c4d4c
4 files changed
+46
-21
No files matched your search
+32
-15
@@ -88,6 +88,12 @@ struct ClientInfo {
|
||||
database_id: u64,
|
||||
channel_group: u64,
|
||||
server_groups: Vec<u64>,
|
||||
/// Whether this client is currently allowed to talk in their channel -
|
||||
/// `false` in a moderated channel (one with a talk power requirement)
|
||||
/// when the client's talk power is below that requirement and they
|
||||
/// haven't been individually granted talk power. Always `true` in a
|
||||
/// non-moderated channel.
|
||||
has_talk_power: bool,
|
||||
}
|
||||
|
||||
/// Payload for the "serveredit " stdin command - every field is optional so
|
||||
@@ -535,21 +541,32 @@ fn snapshot(con: &data::Connection) -> Event {
|
||||
let clients = con
|
||||
.clients
|
||||
.values()
|
||||
.map(|c| ClientInfo {
|
||||
id: c.id.0,
|
||||
channel: c.channel.0,
|
||||
name: c.name.clone(),
|
||||
input_muted: c.input_muted,
|
||||
output_muted: c.output_muted,
|
||||
input_hardware_enabled: c.input_hardware_enabled,
|
||||
away: c.away_message.is_some(),
|
||||
away_message: c.away_message.clone().unwrap_or_default(),
|
||||
is_channel_commander: c.is_channel_commander,
|
||||
country: c.country_code.clone(),
|
||||
uid: c.uid.as_ref().map(|u| u.to_string()).unwrap_or_default(),
|
||||
database_id: c.database_id.0,
|
||||
channel_group: c.channel_group.0,
|
||||
server_groups: c.server_groups.iter().map(|g| g.0).collect(),
|
||||
.map(|c| {
|
||||
// A channel with no talk power requirement at all (the common
|
||||
// case) is never moderated, so everyone can talk regardless of
|
||||
// their own talk power - matches tsclientlib's own
|
||||
// intern_can_send_audio logic for the moderated-channel check.
|
||||
let has_talk_power = match con.channels.get(&c.channel).and_then(|ch| ch.needed_talk_power) {
|
||||
Some(needed) => c.talk_power_granted || c.talk_power >= needed,
|
||||
None => true,
|
||||
};
|
||||
ClientInfo {
|
||||
id: c.id.0,
|
||||
channel: c.channel.0,
|
||||
name: c.name.clone(),
|
||||
input_muted: c.input_muted,
|
||||
output_muted: c.output_muted,
|
||||
input_hardware_enabled: c.input_hardware_enabled,
|
||||
away: c.away_message.is_some(),
|
||||
away_message: c.away_message.clone().unwrap_or_default(),
|
||||
is_channel_commander: c.is_channel_commander,
|
||||
country: c.country_code.clone(),
|
||||
uid: c.uid.as_ref().map(|u| u.to_string()).unwrap_or_default(),
|
||||
database_id: c.database_id.0,
|
||||
channel_group: c.channel_group.0,
|
||||
server_groups: c.server_groups.iter().map(|g| g.0).collect(),
|
||||
has_talk_power,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
Event::Channels { channels, clients }
|
||||
|
||||
@@ -36,6 +36,7 @@ export interface ClientInfo {
|
||||
databaseId: number;
|
||||
channelGroup: number;
|
||||
serverGroups: number[];
|
||||
hasTalkPower: boolean;
|
||||
}
|
||||
|
||||
export interface GroupEntry {
|
||||
@@ -233,6 +234,7 @@ export class Ts3Connection {
|
||||
database_id: number;
|
||||
channel_group: number;
|
||||
server_groups: number[];
|
||||
has_talk_power: boolean;
|
||||
}
|
||||
|
||||
interface RawChannelInfo {
|
||||
@@ -387,6 +389,7 @@ export class Ts3Connection {
|
||||
databaseId: c.database_id,
|
||||
channelGroup: c.channel_group,
|
||||
serverGroups: c.server_groups,
|
||||
hasTalkPower: c.has_talk_power,
|
||||
})),
|
||||
});
|
||||
} else if (event.type === "privateMessage") {
|
||||
|
||||
+5
-2
@@ -330,6 +330,7 @@ interface ClientInfo {
|
||||
databaseId: number;
|
||||
channelGroup: number;
|
||||
serverGroups: number[];
|
||||
hasTalkPower: boolean;
|
||||
}
|
||||
|
||||
interface GroupEntry {
|
||||
@@ -533,7 +534,7 @@ function ChannelTree({
|
||||
<li key={c.id}>
|
||||
<div
|
||||
className={`ts-row ts-client-row${c.id === ownClientId ? " ts-self" : ""}${
|
||||
talkers.has(c.id) ? " ts-talking" : ""
|
||||
talkers.has(c.id) && c.hasTalkPower ? " ts-talking" : ""
|
||||
}`}
|
||||
onClick={c.id === ownClientId ? undefined : () => onOpenPrivateChat(c.id, c.name)}
|
||||
onContextMenu={(e) => onClientContextMenu(e, c.id, c.name, c.id === ownClientId)}
|
||||
@@ -5839,7 +5840,9 @@ function AppInner() {
|
||||
const inputMuted = ownClient?.inputMuted ?? false;
|
||||
const outputMuted = ownClient?.outputMuted ?? false;
|
||||
const displayTalkers =
|
||||
selfActive && !inputMuted && ownClient ? new Set(talkers).add(ownClient.id) : talkers;
|
||||
selfActive && !inputMuted && ownClient?.hasTalkPower
|
||||
? new Set(talkers).add(ownClient.id)
|
||||
: talkers;
|
||||
const t = useT();
|
||||
|
||||
return (
|
||||
|
||||
+6
-4
@@ -33,6 +33,7 @@ interface DemoClient {
|
||||
databaseId: number;
|
||||
channelGroup: number;
|
||||
serverGroups: number[];
|
||||
hasTalkPower: boolean;
|
||||
}
|
||||
|
||||
const DEMO_CHANNELS: DemoChannel[] = [
|
||||
@@ -56,10 +57,10 @@ const DEMO_SERVER_GROUPS = [
|
||||
];
|
||||
|
||||
const DEMO_NPCS: DemoClient[] = [
|
||||
{ id: 102, channel: 1, name: "Alex", inputMuted: false, outputMuted: false, inputHardwareEnabled: true, away: false, awayMessage: "", isChannelCommander: true, country: "US", uid: "demo-uid-alex", databaseId: 2, channelGroup: 2, serverGroups: [2] },
|
||||
{ id: 103, channel: 2, name: "Sam", inputMuted: false, outputMuted: false, inputHardwareEnabled: true, away: false, awayMessage: "", isChannelCommander: false, country: "GB", uid: "demo-uid-sam", databaseId: 3, channelGroup: 4, serverGroups: [4] },
|
||||
{ id: 104, channel: 2, name: "Jordan", inputMuted: true, outputMuted: false, inputHardwareEnabled: true, away: false, awayMessage: "", isChannelCommander: false, country: "CA", uid: "demo-uid-jordan", databaseId: 4, channelGroup: 4, serverGroups: [4] },
|
||||
{ id: 105, channel: 3, name: "Riley", inputMuted: false, outputMuted: false, inputHardwareEnabled: true, away: true, awayMessage: "brb, grabbing coffee", isChannelCommander: false, country: "DE", uid: "demo-uid-riley", databaseId: 5, channelGroup: 4, serverGroups: [3, 4] },
|
||||
{ id: 102, channel: 1, name: "Alex", inputMuted: false, outputMuted: false, inputHardwareEnabled: true, away: false, awayMessage: "", isChannelCommander: true, country: "US", uid: "demo-uid-alex", databaseId: 2, channelGroup: 2, serverGroups: [2], hasTalkPower: true },
|
||||
{ id: 103, channel: 2, name: "Sam", inputMuted: false, outputMuted: false, inputHardwareEnabled: true, away: false, awayMessage: "", isChannelCommander: false, country: "GB", uid: "demo-uid-sam", databaseId: 3, channelGroup: 4, serverGroups: [4], hasTalkPower: true },
|
||||
{ id: 104, channel: 2, name: "Jordan", inputMuted: true, outputMuted: false, inputHardwareEnabled: true, away: false, awayMessage: "", isChannelCommander: false, country: "CA", uid: "demo-uid-jordan", databaseId: 4, channelGroup: 4, serverGroups: [4], hasTalkPower: true },
|
||||
{ id: 105, channel: 3, name: "Riley", inputMuted: false, outputMuted: false, inputHardwareEnabled: true, away: true, awayMessage: "brb, grabbing coffee", isChannelCommander: false, country: "DE", uid: "demo-uid-riley", databaseId: 5, channelGroup: 4, serverGroups: [3, 4], hasTalkPower: true },
|
||||
];
|
||||
|
||||
interface DemoFileEntry {
|
||||
@@ -617,6 +618,7 @@ export class DemoSocket {
|
||||
databaseId: 1,
|
||||
channelGroup: this.selfChannelGroup,
|
||||
serverGroups: [...this.selfServerGroups],
|
||||
hasTalkPower: true,
|
||||
};
|
||||
this.emit({ type: "channels", channels: DEMO_CHANNELS, clients: [self, ...DEMO_NPCS] });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user