mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
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:
1 parent
b6448e65e8
commit
701bd867fc
2 files changed
+36
-11
No files matched your search
@@ -1130,10 +1130,17 @@ async fn run(args: Args) -> Result<()> {
|
|||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// Still try with raw ids if the client left our view.
|
// 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 {
|
Some(OutClientMovePart {
|
||||||
client_id: ClientId(clid),
|
client_id: ClientId(clid),
|
||||||
channel_id: ChannelId(cid),
|
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
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
|
|
||||||
/** Only dismiss on a genuine backdrop click, not a text-selection drag that
|
/** Only dismiss on a genuine backdrop click, not a text-selection drag that
|
||||||
@@ -2397,7 +2397,7 @@ function MoveClientDialog({
|
|||||||
<li key={ch.id}>
|
<li key={ch.id}>
|
||||||
<button
|
<button
|
||||||
className={`ts-menu-item${current ? " ts-group-assign-current" : ""}`}
|
className={`ts-menu-item${current ? " ts-group-assign-current" : ""}`}
|
||||||
disabled={current}
|
disabled={current || spacer.isSpacer}
|
||||||
onClick={() => onSelect(ch.id)}
|
onClick={() => onSelect(ch.id)}
|
||||||
>
|
>
|
||||||
<span className="ts-menu-item-icon">
|
<span className="ts-menu-item-icon">
|
||||||
@@ -7189,6 +7189,16 @@ function AppInner() {
|
|||||||
const handleMoveClient = (clientId: number, channelId: number) => {
|
const handleMoveClient = (clientId: number, channelId: number) => {
|
||||||
const client = clients.find((c) => c.id === clientId);
|
const client = clients.find((c) => c.id === clientId);
|
||||||
if (client && client.channel === channelId) return;
|
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(
|
socketRef.current?.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "moveClient",
|
type: "moveClient",
|
||||||
@@ -7481,14 +7491,22 @@ function AppInner() {
|
|||||||
const showServerQueryClients =
|
const showServerQueryClients =
|
||||||
activeFavoriteId != null &&
|
activeFavoriteId != null &&
|
||||||
favorites.some((f) => f.id === activeFavoriteId && f.showServerQueryClients);
|
favorites.some((f) => f.id === activeFavoriteId && f.showServerQueryClients);
|
||||||
const treeClients = showServerQueryClients ? clients : clients.filter((c) => !c.isQuery);
|
// clients can be a large, frequently-unchanged list re-scanned on every
|
||||||
const queryClientCount = clients.reduce((n, c) => n + (c.isQuery ? 1 : 0), 0);
|
// render - including on every "talkers" voice-activity update, which has
|
||||||
const displayClientCount = showServerQueryClients
|
// nothing to do with the client list itself - so memoize on the inputs
|
||||||
? serverClientsOnline > 0
|
// that actually affect the result instead of re-filtering/re-reducing it
|
||||||
? serverClientsOnline + queryClientCount
|
// every time.
|
||||||
: treeClients.length
|
const treeClients = useMemo(
|
||||||
: serverClientsOnline > 0
|
() => (showServerQueryClients ? clients : clients.filter((c) => !c.isQuery)),
|
||||||
? serverClientsOnline
|
[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;
|
: treeClients.length;
|
||||||
const novaSplash = designTheme === "nova" && !connected;
|
const novaSplash = designTheme === "nova" && !connected;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user