mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 09:52:50 +08:00
Add server group icon badges and a 'no talk power' status icon
Group icons were entirely missing from the data model - GroupEntry only carried id/name. Added icon_id (from ServerGroup/ChannelGroup's Icon field) through connector -> gateway -> frontend, matching the same channel-0 icon_<id> file convention already used for server icons (#77), reusing that dialog's fetch/cache/render plumbing (serverIconImages, iconDataUrl). Client rows now render a small badge per server group with a non-zero icon, positioned after the name/status icons (i.e. on the right), instead of not existing at all. Also added a 🔒 status icon for clients who aren't muted but still can't talk due to insufficient talk power in a moderated channel (previously no icon indicated this state at all).
This commit is contained in:
1 parent
6e343c4d4c
commit
b7ef6f78e7
6 files changed
+76
-14
No files matched your search
@@ -368,6 +368,7 @@ struct PermissionCatalogEntry {
|
|||||||
struct GroupEntry {
|
struct GroupEntry {
|
||||||
id: u64,
|
id: u64,
|
||||||
name: String,
|
name: String,
|
||||||
|
icon_id: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Clone)]
|
#[derive(Serialize, Clone)]
|
||||||
@@ -1970,7 +1971,7 @@ async fn run(args: Args) -> Result<()> {
|
|||||||
let mut entries: Vec<GroupEntry> = state
|
let mut entries: Vec<GroupEntry> = state
|
||||||
.channel_groups
|
.channel_groups
|
||||||
.values()
|
.values()
|
||||||
.map(|g| GroupEntry { id: g.id.0, name: g.name.clone() })
|
.map(|g| GroupEntry { id: g.id.0, name: g.name.clone(), icon_id: g.icon.0 })
|
||||||
.collect();
|
.collect();
|
||||||
entries.sort_by_key(|g| g.id);
|
entries.sort_by_key(|g| g.id);
|
||||||
emit(&Event::ChannelGroupList { entries });
|
emit(&Event::ChannelGroupList { entries });
|
||||||
@@ -1980,7 +1981,7 @@ async fn run(args: Args) -> Result<()> {
|
|||||||
let mut entries: Vec<GroupEntry> = state
|
let mut entries: Vec<GroupEntry> = state
|
||||||
.server_groups
|
.server_groups
|
||||||
.values()
|
.values()
|
||||||
.map(|g| GroupEntry { id: g.id.0, name: g.name.clone() })
|
.map(|g| GroupEntry { id: g.id.0, name: g.name.clone(), icon_id: g.icon.0 })
|
||||||
.collect();
|
.collect();
|
||||||
entries.sort_by_key(|g| g.id);
|
entries.sort_by_key(|g| g.id);
|
||||||
emit(&Event::ServerGroupList { entries });
|
emit(&Event::ServerGroupList { entries });
|
||||||
@@ -2110,7 +2111,7 @@ async fn run(args: Args) -> Result<()> {
|
|||||||
if let InMessage::ChannelGroupList(list) = &msg {
|
if let InMessage::ChannelGroupList(list) = &msg {
|
||||||
let entries: Vec<GroupEntry> = list
|
let entries: Vec<GroupEntry> = list
|
||||||
.iter()
|
.iter()
|
||||||
.map(|part| GroupEntry { id: part.channel_group.0, name: part.name.clone() })
|
.map(|part| GroupEntry { id: part.channel_group.0, name: part.name.clone(), icon_id: part.icon.0 })
|
||||||
.collect();
|
.collect();
|
||||||
emit(&Event::ChannelGroupList { entries });
|
emit(&Event::ChannelGroupList { entries });
|
||||||
pending_channel_group_list = false;
|
pending_channel_group_list = false;
|
||||||
@@ -2120,7 +2121,7 @@ async fn run(args: Args) -> Result<()> {
|
|||||||
if let InMessage::ServerGroupList(list) = &msg {
|
if let InMessage::ServerGroupList(list) = &msg {
|
||||||
let entries: Vec<GroupEntry> = list
|
let entries: Vec<GroupEntry> = list
|
||||||
.iter()
|
.iter()
|
||||||
.map(|part| GroupEntry { id: part.server_group_id.0, name: part.name.clone() })
|
.map(|part| GroupEntry { id: part.server_group_id.0, name: part.name.clone(), icon_id: part.icon.0 })
|
||||||
.collect();
|
.collect();
|
||||||
emit(&Event::ServerGroupList { entries });
|
emit(&Event::ServerGroupList { entries });
|
||||||
pending_server_group_list = false;
|
pending_server_group_list = false;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export interface ClientInfo {
|
|||||||
export interface GroupEntry {
|
export interface GroupEntry {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
iconId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PermissionOverviewEntry {
|
export interface PermissionOverviewEntry {
|
||||||
@@ -338,8 +339,8 @@ export class Ts3Connection {
|
|||||||
message: string;
|
message: string;
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
}
|
}
|
||||||
| { type: "channelGroupList"; entries: { id: number; name: string }[] }
|
| { type: "channelGroupList"; entries: GroupEntry[] }
|
||||||
| { type: "serverGroupList"; entries: { id: number; name: string }[] }
|
| { type: "serverGroupList"; entries: GroupEntry[] }
|
||||||
| {
|
| {
|
||||||
type: "permissionOverview";
|
type: "permissionOverview";
|
||||||
entries: { name: string; description: string; value: number; negated: boolean; skip: boolean }[];
|
entries: { name: string; description: string; value: number; negated: boolean; skip: boolean }[];
|
||||||
|
|||||||
@@ -550,6 +550,13 @@
|
|||||||
opacity: 0.85;
|
opacity: 0.85;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ts-group-icon {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
object-fit: contain;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.ts-poke-button {
|
.ts-poke-button {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|||||||
@@ -336,6 +336,7 @@ interface ClientInfo {
|
|||||||
interface GroupEntry {
|
interface GroupEntry {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
iconId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PermissionOverviewEntry {
|
interface PermissionOverviewEntry {
|
||||||
@@ -463,6 +464,9 @@ function ClientStatusIcons({ client }: { client: ClientInfo }) {
|
|||||||
{client.isChannelCommander && <span title={t("tree.channelCommander")}>⭐</span>}
|
{client.isChannelCommander && <span title={t("tree.channelCommander")}>⭐</span>}
|
||||||
{client.away && <span title={t("tree.away")}>💤</span>}
|
{client.away && <span title={t("tree.away")}>💤</span>}
|
||||||
{(client.inputMuted || !client.inputHardwareEnabled) && <span title={t("tree.micMuted")}>🔇</span>}
|
{(client.inputMuted || !client.inputHardwareEnabled) && <span title={t("tree.micMuted")}>🔇</span>}
|
||||||
|
{!client.inputMuted && client.inputHardwareEnabled && !client.hasTalkPower && (
|
||||||
|
<span title={t("tree.noTalkPower")}>🔒</span>
|
||||||
|
)}
|
||||||
{client.outputMuted && <span title={t("tree.soundMuted")}>🔕</span>}
|
{client.outputMuted && <span title={t("tree.soundMuted")}>🔕</span>}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
@@ -485,6 +489,8 @@ function ChannelTree({
|
|||||||
parent,
|
parent,
|
||||||
ownClientId,
|
ownClientId,
|
||||||
talkers,
|
talkers,
|
||||||
|
serverGroups,
|
||||||
|
groupIconImages,
|
||||||
selected,
|
selected,
|
||||||
onSelectItem,
|
onSelectItem,
|
||||||
onSwitchChannel,
|
onSwitchChannel,
|
||||||
@@ -498,6 +504,8 @@ function ChannelTree({
|
|||||||
parent: number;
|
parent: number;
|
||||||
ownClientId: number | null;
|
ownClientId: number | null;
|
||||||
talkers: Set<number>;
|
talkers: Set<number>;
|
||||||
|
serverGroups: GroupEntry[] | null;
|
||||||
|
groupIconImages: Record<string, string>;
|
||||||
selected: SelectedItem | null;
|
selected: SelectedItem | null;
|
||||||
onSelectItem: (item: SelectedItem) => void;
|
onSelectItem: (item: SelectedItem) => void;
|
||||||
onSwitchChannel: (channelId: number) => void;
|
onSwitchChannel: (channelId: number) => void;
|
||||||
@@ -510,6 +518,13 @@ function ChannelTree({
|
|||||||
const children = channels.filter((c) => c.parent === parent).sort((a, b) => a.order - b.order);
|
const children = channels.filter((c) => c.parent === parent).sort((a, b) => a.order - b.order);
|
||||||
if (children.length === 0) return null;
|
if (children.length === 0) return null;
|
||||||
|
|
||||||
|
const groupIconIds = (client: ClientInfo): number[] =>
|
||||||
|
serverGroups
|
||||||
|
? client.serverGroups
|
||||||
|
.map((gid) => serverGroups.find((g) => g.id === gid)?.iconId ?? 0)
|
||||||
|
.filter((iconId) => iconId !== 0)
|
||||||
|
: [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul className="ts-tree-list">
|
<ul className="ts-tree-list">
|
||||||
{children.map((channel) => (
|
{children.map((channel) => (
|
||||||
@@ -547,6 +562,12 @@ function ChannelTree({
|
|||||||
<span className="ts-client-away-message">({c.awayMessage})</span>
|
<span className="ts-client-away-message">({c.awayMessage})</span>
|
||||||
)}
|
)}
|
||||||
<ClientStatusIcons client={c} />
|
<ClientStatusIcons client={c} />
|
||||||
|
{groupIconIds(c).map((iconId) => {
|
||||||
|
const base64 = groupIconImages[`/icon_${iconId}`];
|
||||||
|
return base64 ? (
|
||||||
|
<img key={iconId} className="ts-group-icon" src={iconDataUrl(base64)} alt="" />
|
||||||
|
) : null;
|
||||||
|
})}
|
||||||
{c.id !== ownClientId && (
|
{c.id !== ownClientId && (
|
||||||
<button
|
<button
|
||||||
className="ts-poke-button"
|
className="ts-poke-button"
|
||||||
@@ -569,6 +590,8 @@ function ChannelTree({
|
|||||||
parent={channel.id}
|
parent={channel.id}
|
||||||
ownClientId={ownClientId}
|
ownClientId={ownClientId}
|
||||||
talkers={talkers}
|
talkers={talkers}
|
||||||
|
serverGroups={serverGroups}
|
||||||
|
groupIconImages={groupIconImages}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
onSelectItem={onSelectItem}
|
onSelectItem={onSelectItem}
|
||||||
onSwitchChannel={onSwitchChannel}
|
onSwitchChannel={onSwitchChannel}
|
||||||
@@ -4899,6 +4922,32 @@ function AppInner() {
|
|||||||
}
|
}
|
||||||
}, [serverIconsOpen, serverIconEntries, serverIconImages]);
|
}, [serverIconsOpen, serverIconEntries, serverIconImages]);
|
||||||
|
|
||||||
|
// Server group badges next to client names need the group list (for the
|
||||||
|
// id->icon lookup) even if the user never opens a group-related dialog -
|
||||||
|
// fetch it once per connection instead of only on demand.
|
||||||
|
useEffect(() => {
|
||||||
|
if (!connected || serverGroups) return;
|
||||||
|
socketRef.current?.send(JSON.stringify({ type: "getServerGroupList" }));
|
||||||
|
}, [connected, serverGroups]);
|
||||||
|
|
||||||
|
// Same icon-file cache as the server icons dialog (fileDownloadData for
|
||||||
|
// cid 0 always lands in serverIconImages, regardless of who asked) - fetch
|
||||||
|
// any group icon referenced by a currently visible client that isn't
|
||||||
|
// cached yet.
|
||||||
|
useEffect(() => {
|
||||||
|
if (!serverGroups) return;
|
||||||
|
const iconById = new Map(serverGroups.map((g) => [g.id, g.iconId]));
|
||||||
|
const wantedIconIds = new Set(
|
||||||
|
clients.flatMap((c) => c.serverGroups.map((gid) => iconById.get(gid) ?? 0)).filter((id) => id !== 0)
|
||||||
|
);
|
||||||
|
for (const iconId of wantedIconIds) {
|
||||||
|
const path = `/icon_${iconId}`;
|
||||||
|
if (!(path in serverIconImages)) {
|
||||||
|
socketRef.current?.send(JSON.stringify({ type: "downloadFile", channelId: 0, path }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [clients, serverGroups, serverIconImages]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
setWhisperChannelIds(new Set());
|
setWhisperChannelIds(new Set());
|
||||||
@@ -7198,6 +7247,8 @@ function AppInner() {
|
|||||||
parent={0}
|
parent={0}
|
||||||
ownClientId={ownClient?.id ?? null}
|
ownClientId={ownClient?.id ?? null}
|
||||||
talkers={displayTalkers}
|
talkers={displayTalkers}
|
||||||
|
serverGroups={serverGroups}
|
||||||
|
groupIconImages={serverIconImages}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
onSelectItem={handleSelectItem}
|
onSelectItem={handleSelectItem}
|
||||||
onSwitchChannel={handleSwitchChannel}
|
onSwitchChannel={handleSwitchChannel}
|
||||||
|
|||||||
+8
-8
@@ -43,17 +43,17 @@ const DEMO_CHANNELS: DemoChannel[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const DEMO_CHANNEL_GROUPS = [
|
const DEMO_CHANNEL_GROUPS = [
|
||||||
{ id: 1, name: "Channel Admin" },
|
{ id: 1, name: "Channel Admin", iconId: 0 },
|
||||||
{ id: 2, name: "Operator" },
|
{ id: 2, name: "Operator", iconId: 0 },
|
||||||
{ id: 3, name: "Voice" },
|
{ id: 3, name: "Voice", iconId: 0 },
|
||||||
{ id: 4, name: "Guest" },
|
{ id: 4, name: "Guest", iconId: 0 },
|
||||||
];
|
];
|
||||||
|
|
||||||
const DEMO_SERVER_GROUPS = [
|
const DEMO_SERVER_GROUPS = [
|
||||||
{ id: 1, name: "Server Admin" },
|
{ id: 1, name: "Server Admin", iconId: 0 },
|
||||||
{ id: 2, name: "Moderator" },
|
{ id: 2, name: "Moderator", iconId: 0 },
|
||||||
{ id: 3, name: "Trusted" },
|
{ id: 3, name: "Trusted", iconId: 0 },
|
||||||
{ id: 4, name: "Guest" },
|
{ id: 4, name: "Guest", iconId: 0 },
|
||||||
];
|
];
|
||||||
|
|
||||||
const DEMO_NPCS: DemoClient[] = [
|
const DEMO_NPCS: DemoClient[] = [
|
||||||
|
|||||||
@@ -291,6 +291,7 @@ const translations: Record<Lang, Record<string, string>> = {
|
|||||||
"tree.channelCommander": "Channel Commander",
|
"tree.channelCommander": "Channel Commander",
|
||||||
"tree.away": "Abwesend",
|
"tree.away": "Abwesend",
|
||||||
"tree.micMuted": "Mikrofon stummgeschaltet",
|
"tree.micMuted": "Mikrofon stummgeschaltet",
|
||||||
|
"tree.noTalkPower": "Keine Redeerlaubnis in diesem Channel",
|
||||||
"tree.soundMuted": "Ton stummgeschaltet (deafened)",
|
"tree.soundMuted": "Ton stummgeschaltet (deafened)",
|
||||||
|
|
||||||
"chat.server": "Server",
|
"chat.server": "Server",
|
||||||
@@ -791,6 +792,7 @@ const translations: Record<Lang, Record<string, string>> = {
|
|||||||
"tree.channelCommander": "Channel commander",
|
"tree.channelCommander": "Channel commander",
|
||||||
"tree.away": "Away",
|
"tree.away": "Away",
|
||||||
"tree.micMuted": "Microphone muted",
|
"tree.micMuted": "Microphone muted",
|
||||||
|
"tree.noTalkPower": "No talk power in this channel",
|
||||||
"tree.soundMuted": "Sound muted (deafened)",
|
"tree.soundMuted": "Sound muted (deafened)",
|
||||||
|
|
||||||
"chat.server": "Server",
|
"chat.server": "Server",
|
||||||
|
|||||||
Reference in new issue
Block a user