diff --git a/code/modules/modular_computers/file_system/programs/chatroom/ntnrc_client.dm b/code/modules/modular_computers/file_system/programs/chatroom/ntnrc_client.dm index 9cd92c5fe6d..9e7385c0b65 100644 --- a/code/modules/modular_computers/file_system/programs/chatroom/ntnrc_client.dm +++ b/code/modules/modular_computers/file_system/programs/chatroom/ntnrc_client.dm @@ -4,6 +4,10 @@ #define PING_COOLDOWN_TIME (3 SECONDS) +#define STATUS_ONLINE 3 +#define STATUS_AWAY 2 +#define STATUS_OFFLINE 1 + /datum/computer_file/program/chatclient filename = "ntnrc_client" filedesc = "Chat Client" @@ -208,6 +212,14 @@ active_channel = null return ..() +/// Converts active/idle/closed to a numerical status for sorting clients by. +/datum/computer_file/program/chatclient/proc/get_numerical_status() + if(src == computer.active_program) + return STATUS_ONLINE + if(src in computer.idle_threads) + return STATUS_AWAY + return STATUS_OFFLINE + /datum/computer_file/program/chatclient/ui_static_data(mob/user) var/list/data = list() data["selfref"] = REF(src) //used to verify who is you, as usernames can be copied. @@ -244,6 +256,7 @@ "away" = (channel_client in channel_client.computer.idle_threads), "muted" = (channel_client in channel.muted_clients), "operator" = (channel.channel_operator == channel_client), + "status" = channel_client.get_numerical_status(), "ref" = REF(channel_client), ))) //no fishing for ui data allowed @@ -269,3 +282,7 @@ #undef MESSAGE_SIZE #undef PING_COOLDOWN_TIME + +#undef STATUS_ONLINE +#undef STATUS_AWAY +#undef STATUS_OFFLINE diff --git a/tgui/packages/tgui/interfaces/NtosNetChat.jsx b/tgui/packages/tgui/interfaces/NtosNetChat.jsx index 650520dd3a5..61f4a7998cc 100644 --- a/tgui/packages/tgui/interfaces/NtosNetChat.jsx +++ b/tgui/packages/tgui/interfaces/NtosNetChat.jsx @@ -62,15 +62,13 @@ export const NtosNetChat = (props) => { } = data; const in_channel = active_channel !== null; const authorized = authed || adminmode; - // this list has cliented ordered from their status. online > away > offline + // This list has clients ordered by operator>status>alphabetical const displayed_clients = clients.sort((clientA, clientB) => { - if (clientA.operator) { - return -1; - } - if (clientB.operator) { - return 1; - } - return clientB.status - clientA.status; + return ( + clientB.operator - clientA.operator || + clientB.status - clientA.status || + clientB.name < clientA.name + ); }); const client_color = (client) => { if (client.operator) {