Answer what the local client may do from the model

The Swing client menu decided on its own whether a group can be
(un)assigned and whether a client's channel can be joined, and the
server groups dialog borrowed the menu's check. These are rules about
the server, not about menus, so ServerModel answers them now and any
frontend asks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 08:10:54 +00:00
parent 8f385b9343
commit fecb2ba8f4
5 changed files with 121 additions and 69 deletions

View File

@@ -82,14 +82,12 @@ final class ServerGroupsDialog extends JDialog {
}
header.setText(client.nickname);
int addPower = conn.getModel().selfPermissionValue("i_group_needed_member_add_power");
int removePower = conn.getModel().selfPermissionValue("i_group_needed_member_remove_power");
List<Group> groups = conn.getModel().allServerGroups();
list.removeAll();
for (Group g : groups) {
boolean assigned = contains(client.serverGroupIds, g.id);
boolean allowed = ClientMenu.canAssign(g, assigned, addPower, removePower);
boolean assigned = client.inServerGroup(g.id);
boolean allowed = conn.getModel().canToggleGroup(g, assigned);
ImageIcon icon = groupIcons.iconOf(g);
JCheckBox box = new JCheckBox(g.name, allowed ? icon : grayscale(icon));
@@ -110,9 +108,4 @@ final class ServerGroupsDialog extends JDialog {
return grayscale.computeIfAbsent(icon,
i -> new ImageIcon(GrayFilter.createDisabledImage(i.getImage())));
}
private static boolean contains(int[] ids, int id) {
for (int i : ids) if (i == id) return true;
return false;
}
}