Hide 'Transfer file' and 'TCP tunneling' menu items in relay mode
Plan B for the punch UI: don't just grey out file transfer — hide it entirely when the connection is relay. The user can't try to use it, and we save the toast explanation. When punch succeeds (P2P, direct), the menu items reappear. Applied to: - Transfer file - TCP tunneling (Leaving View camera and Terminal in the menu regardless of mode — they don't use server bandwidth significantly.)
This commit is contained in:
@@ -451,17 +451,25 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
||||
}
|
||||
|
||||
if (isDefaultConn && isDesktop) {
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Text(translate('Transfer file')),
|
||||
onPressed: () {
|
||||
if (!isDirectConnection(id)) {
|
||||
showToast('中继模式:当前连接走服务器 21117 中转,文件传输已被禁用以避免占用过多服务器带宽。');
|
||||
return;
|
||||
}
|
||||
connectWithToken(isFileTransfer: true);
|
||||
}),
|
||||
);
|
||||
// Custom fork: only show the "Transfer file" and "TCP tunneling" menu
|
||||
// items when the connection is P2P (direct). In relay mode, hide them
|
||||
// entirely so the user can't even try. Reason: server bandwidth is
|
||||
// scarce (5 Mbps for 4 users) and a single file transfer can saturate
|
||||
// it; better to surface the limitation up-front than show a disabled
|
||||
// grey item with a toast.
|
||||
final showP2POnlyMenus = isDirectConnection(id);
|
||||
if (showP2POnlyMenus) {
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Text(translate('Transfer file')),
|
||||
onPressed: () => connectWithToken(isFileTransfer: true)),
|
||||
);
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Text(translate('TCP tunneling')),
|
||||
onPressed: () => connectWithToken(isTcpTunneling: true)),
|
||||
);
|
||||
}
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Text(translate('View camera')),
|
||||
@@ -472,17 +480,6 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
||||
child: Text('${translate('Terminal')} (beta)'),
|
||||
onPressed: () => connectWithToken(isTerminal: true)),
|
||||
);
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Text(translate('TCP tunneling')),
|
||||
onPressed: () {
|
||||
if (!isDirectConnection(id)) {
|
||||
showToast('中继模式:TCP 隧道已被禁用以避免占用过多服务器带宽。');
|
||||
return;
|
||||
}
|
||||
connectWithToken(isTcpTunneling: true);
|
||||
}),
|
||||
);
|
||||
}
|
||||
// note
|
||||
if (isDefaultConn && !bind.isDisableAccount()) {
|
||||
|
||||
Reference in New Issue
Block a user