Files
factorio-clusterio/packages/web_ui/src/components/OnlinePlayersList.tsx
T
BastiaanandClaude Opus 5.5 ae707f7768 Always show the instance player list, collapsed when empty (#1197)
The list used to disappear when nobody was online. It is now a Collapse
that opens while players are online and closes when the last one leaves.
Once the user toggles it, their choice sticks for the page.

Fixes #1191

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 17:40:37 +00:00

36 lines
1.1 KiB
TypeScript

import React, { useState } from "react";
import { Collapse } from "antd";
import { useUsers } from "../model/user";
import UsersTable from "./UsersTable";
type OnlinePlayersListProps = {
instanceId: number;
};
export default function OnlinePlayersList({ instanceId }: OnlinePlayersListProps) {
const [users] = useUsers();
// undefined until the user toggles the panel, then their choice sticks.
const [open, setOpen] = useState<boolean>();
const onlineCount = [...users.values()].filter(user => user.instances?.has(instanceId)).length;
const expanded = open ?? onlineCount > 0;
return <Collapse
size="small"
style={{ marginTop: 16 }}
activeKey={expanded ? ["players"] : []}
onChange={keys => setOpen(keys.length > 0)}
items={[{
key: "players",
label: `Online Players (${onlineCount})`,
children: <UsersTable instanceId={instanceId} onlyOnline size="small" pagination={{
defaultPageSize: 10,
showSizeChanger: true,
pageSizeOptions: ["10", "20", "50", "100", "200"],
showTotal: (total: number) => `${total} Users`,
}} />,
}]}
/>;
}