Hide "Browse files" without the permission to list files

The channel menu (desktop) and channel sheet (Android) leave the entry out
when i_ft_file_browse_power is 0. Unlike move/kick/ban powers it is among the
needed permissions the server reports, and with it at 0 ftgetfilelist is
refused even where the channel needs no power (verified on a local 3.13.7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-10 21:02:45 +00:00
co-authored by Claude Opus 5.5
parent 801dfa39ab
commit d3731e297b
7 changed files with 26 additions and 7 deletions
@@ -270,6 +270,7 @@ class ServerController internal constructor(
val canKickFromServer: Boolean get() = session.canKickFromServer()
val canBanClients: Boolean get() = session.canBanClients()
val canViewBanList: Boolean get() = session.canViewBanList()
val canBrowseFiles: Boolean get() = session.canBrowseFiles()
val canCreateBans: Boolean get() = session.isConnected && conn.model.permits("b_client_ban_create")
/** The longest ban we may hand out in seconds; 0 or -1 for no limit. */
@@ -434,10 +434,10 @@ fun ServerScreen(
channelSheet = null
server.channelRef(id)?.let { ref -> toWhisperList = channel.name to { it.channels.add(ref) } }
},
onFiles = {
onFiles = if (server.canBrowseFiles) ({
channelSheet = null
if (channel.locked) filesLocked = id else files = FilesOf(id, channel.name, "")
},
}) else null,
onCreateSub = if (server.canCreateChannels) ({ channelSheet = null; channelEdit = ChannelEdit(0, id) }) else null,
onEdit = if (server.canEditChannels) ({ channelSheet = null; channelEdit = ChannelEdit(id) }) else null,
onDelete = if (server.canDeleteChannels) ({ channelSheet = null; deletingChannel = id }) else null,
@@ -147,8 +147,8 @@ fun ChannelSheet(
onBookmark: () -> Unit,
onWhisper: () -> Unit,
onAddToWhisperList: () -> Unit,
onFiles: () -> Unit,
/** Each null when we may not. */
onFiles: (() -> Unit)?,
onCreateSub: (() -> Unit)?,
onEdit: (() -> Unit)?,
onDelete: (() -> Unit)?,
@@ -168,7 +168,7 @@ fun ChannelSheet(
}
Action("WHISPER", "Whisper", onClick = onWhisper)
Action("ON_WHISPERLIST", "Add to whisper list…", onClick = onAddToWhisperList)
Action("FILETRANSFER", "Browse files", onClick = onFiles)
onFiles?.let { Action("FILETRANSFER", "Browse files", onClick = it) }
Action("BOOKMARK_ADD", "Add to bookmarks", onClick = onBookmark)
onCreateSub?.let { Action("CHANNEL_CREATE_SUB", "Create sub-channel", onClick = it) }
onEdit?.let { Action("CHANNEL_EDIT", "Edit channel", onClick = it) }
@@ -637,6 +637,14 @@ public final class ServerSession {
return permits("b_virtualserver_token_list");
}
/**
* Whether the server lets us list channel files ({@code i_ft_file_browse_power}); offered while
* unknown. A channel may still need more power than we have, which only the server knows.
*/
public boolean canBrowseFiles() {
return permits("i_ft_file_browse_power");
}
/** Whether the server lets us upload an avatar ({@code i_client_max_avatar_filesize}); offered while unknown. */
public boolean canSetAvatar() {
return permits("i_client_max_avatar_filesize");
@@ -37,9 +37,11 @@ final class ChannelMenu {
menu.add(delete);
menu.addSeparator();
addSubscriptionItems(menu, channel, actions);
JMenuItem files = new JMenuItem("Browse files", Icons.of("FILETRANSFER"));
files.addActionListener(a -> actions.browseFiles(channel));
menu.add(files);
if (actions.canBrowseFiles()) {
JMenuItem files = new JMenuItem("Browse files", Icons.of("FILETRANSFER"));
files.addActionListener(a -> actions.browseFiles(channel));
menu.add(files);
}
return menu;
}
@@ -340,6 +340,11 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
return conn.isConnected();
}
@Override
public boolean canBrowseFiles() {
return tab.session().canBrowseFiles();
}
@Override
public void browseFiles(ChannelNode channel) {
if (!conn.canTransferFiles()) return;
@@ -81,6 +81,9 @@ public final class ServerTreePanel extends JPanel {
/** Whether the server is there to act on at all. */
boolean isConnected();
/** Whether we may list channel files at all. */
boolean canBrowseFiles();
/** Open the file repository browser for a channel. */
void browseFiles(ChannelNode channel);