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:
Moepchi committed 2026-08-10 19:11:03 +02:00
1 parent 6e343c4d4c
commit b7ef6f78e7
6 files changed
+76 -14

No files matched your search

+7
View File
@@ -550,6 +550,13 @@
opacity: 0.85;
}
.ts-group-icon {
width: 14px;
height: 14px;
object-fit: contain;
flex-shrink: 0;
}
.ts-poke-button {
margin-left: auto;
background: transparent;
+51
View File
@@ -336,6 +336,7 @@ interface ClientInfo {
interface GroupEntry {
id: number;
name: string;
iconId: number;
}
interface PermissionOverviewEntry {
@@ -463,6 +464,9 @@ function ClientStatusIcons({ client }: { client: ClientInfo }) {
{client.isChannelCommander && <span title={t("tree.channelCommander")}>⭐</span>}
{client.away && <span title={t("tree.away")}>💤</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>}
</span>
);
@@ -485,6 +489,8 @@ function ChannelTree({
parent,
ownClientId,
talkers,
serverGroups,
groupIconImages,
selected,
onSelectItem,
onSwitchChannel,
@@ -498,6 +504,8 @@ function ChannelTree({
parent: number;
ownClientId: number | null;
talkers: Set<number>;
serverGroups: GroupEntry[] | null;
groupIconImages: Record<string, string>;
selected: SelectedItem | null;
onSelectItem: (item: SelectedItem) => 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);
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 (
<ul className="ts-tree-list">
{children.map((channel) => (
@@ -547,6 +562,12 @@ function ChannelTree({
<span className="ts-client-away-message">({c.awayMessage})</span>
)}
<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 && (
<button
className="ts-poke-button"
@@ -569,6 +590,8 @@ function ChannelTree({
parent={channel.id}
ownClientId={ownClientId}
talkers={talkers}
serverGroups={serverGroups}
groupIconImages={groupIconImages}
selected={selected}
onSelectItem={onSelectItem}
onSwitchChannel={onSwitchChannel}
@@ -4899,6 +4922,32 @@ function AppInner() {
}
}, [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(() => {
if (!connected) {
setWhisperChannelIds(new Set());
@@ -7198,6 +7247,8 @@ function AppInner() {
parent={0}
ownClientId={ownClient?.id ?? null}
talkers={displayTalkers}
serverGroups={serverGroups}
groupIconImages={serverIconImages}
selected={selected}
onSelectItem={handleSelectItem}
onSwitchChannel={handleSwitchChannel}
+8 -8
View File
@@ -43,17 +43,17 @@ const DEMO_CHANNELS: DemoChannel[] = [
];
const DEMO_CHANNEL_GROUPS = [
{ id: 1, name: "Channel Admin" },
{ id: 2, name: "Operator" },
{ id: 3, name: "Voice" },
{ id: 4, name: "Guest" },
{ id: 1, name: "Channel Admin", iconId: 0 },
{ id: 2, name: "Operator", iconId: 0 },
{ id: 3, name: "Voice", iconId: 0 },
{ id: 4, name: "Guest", iconId: 0 },
];
const DEMO_SERVER_GROUPS = [
{ id: 1, name: "Server Admin" },
{ id: 2, name: "Moderator" },
{ id: 3, name: "Trusted" },
{ id: 4, name: "Guest" },
{ id: 1, name: "Server Admin", iconId: 0 },
{ id: 2, name: "Moderator", iconId: 0 },
{ id: 3, name: "Trusted", iconId: 0 },
{ id: 4, name: "Guest", iconId: 0 },
];
const DEMO_NPCS: DemoClient[] = [
+2
View File
@@ -291,6 +291,7 @@ const translations: Record<Lang, Record<string, string>> = {
"tree.channelCommander": "Channel Commander",
"tree.away": "Abwesend",
"tree.micMuted": "Mikrofon stummgeschaltet",
"tree.noTalkPower": "Keine Redeerlaubnis in diesem Channel",
"tree.soundMuted": "Ton stummgeschaltet (deafened)",
"chat.server": "Server",
@@ -791,6 +792,7 @@ const translations: Record<Lang, Record<string, string>> = {
"tree.channelCommander": "Channel commander",
"tree.away": "Away",
"tree.micMuted": "Microphone muted",
"tree.noTalkPower": "No talk power in this channel",
"tree.soundMuted": "Sound muted (deafened)",
"chat.server": "Server",