fix: self-move channel password prompt, spacer targets, client-list memoization

- handleMoveClient: route self-drags through handleSwitchChannel so
  moving your own client still prompts for a channel password when
  required, while admin moves of other clients keep bypassing the
  target channel's password (matches native TS3/GTS behavior - only
  the mover needs permission, not the password).
- MoveClientDialog: disable channel spacers as move targets, they are
  display-only rows with no backing channel.
- connector moveclient handler: carry the already-decoded password
  through the fallback branch (client not found in local state)
  instead of hardcoding an empty password, so self-moves via that
  path still authenticate correctly.
- App.tsx: memoize treeClients/queryClientCount so they are not
  recomputed on every render (e.g. on unrelated "talkers" updates),
  and simplify the duplicated displayClientCount ternary.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
MoepchiandClaude Sonnet 5 committed 2026-09-06 11:57:30 +02:00
1 parent b6448e65e8
commit 701bd867fc
2 files changed
+36 -11

No files matched your search

+8 -1
View File
@@ -1130,10 +1130,17 @@ async fn run(args: Args) -> Result<()> {
}
None => {
// Still try with raw ids if the client left our view.
// Carry through the already-decoded password instead of
// dropping it - this path is also used for self-moves
// via drag-and-drop, which still need the password to
// reach the server when the target channel requires one.
Some(OutClientMovePart {
client_id: ClientId(clid),
channel_id: ChannelId(cid),
channel_password: Some(Cow::Borrowed("")),
channel_password: Some(match &password {
Some(pwd) => Cow::Owned(pwd.clone()),
None => Cow::Borrowed(""),
}),
})
}
},
+28 -10
View File
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from "react";
import { useEffect, useMemo, useRef, useState } from "react";
import "./App.css";
/** Only dismiss on a genuine backdrop click, not a text-selection drag that
@@ -2397,7 +2397,7 @@ function MoveClientDialog({
<li key={ch.id}>
<button
className={`ts-menu-item${current ? " ts-group-assign-current" : ""}`}
disabled={current}
disabled={current || spacer.isSpacer}
onClick={() => onSelect(ch.id)}
>
<span className="ts-menu-item-icon">
@@ -7189,6 +7189,16 @@ function AppInner() {
const handleMoveClient = (clientId: number, channelId: number) => {
const client = clients.find((c) => c.id === clientId);
if (client && client.channel === channelId) return;
// Moving yourself (e.g. dragging your own row) is a plain channel join,
// not an admin action - route it through the normal switch flow so it
// only needs join permission and still prompts for a channel password
// when required. The `moveClient` command below is for moving OTHER
// clients, which - like the native client - bypasses the target
// channel's password for whoever holds the move permission.
if (clientId === ownClientId) {
handleSwitchChannel(channelId);
return;
}
socketRef.current?.send(
JSON.stringify({
type: "moveClient",
@@ -7481,14 +7491,22 @@ function AppInner() {
const showServerQueryClients =
activeFavoriteId != null &&
favorites.some((f) => f.id === activeFavoriteId && f.showServerQueryClients);
const treeClients = showServerQueryClients ? clients : clients.filter((c) => !c.isQuery);
const queryClientCount = clients.reduce((n, c) => n + (c.isQuery ? 1 : 0), 0);
const displayClientCount = showServerQueryClients
? serverClientsOnline > 0
? serverClientsOnline + queryClientCount
: treeClients.length
: serverClientsOnline > 0
? serverClientsOnline
// clients can be a large, frequently-unchanged list re-scanned on every
// render - including on every "talkers" voice-activity update, which has
// nothing to do with the client list itself - so memoize on the inputs
// that actually affect the result instead of re-filtering/re-reducing it
// every time.
const treeClients = useMemo(
() => (showServerQueryClients ? clients : clients.filter((c) => !c.isQuery)),
[clients, showServerQueryClients]
);
const queryClientCount = useMemo(
() => clients.reduce((n, c) => n + (c.isQuery ? 1 : 0), 0),
[clients]
);
const displayClientCount =
serverClientsOnline > 0
? serverClientsOnline + (showServerQueryClients ? queryClientCount : 0)
: treeClients.length;
const novaSplash = designTheme === "nova" && !connected;