Skip to content

Commit

Permalink
Admin only: Add online users card
Browse files Browse the repository at this point in the history
  • Loading branch information
SupertigerDev committed Dec 23, 2024
1 parent 98034ef commit d1bddf3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/moderation-pane/ModerationPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ const [stats, setStats] = createSignal<ModerationStats | null>(null);

export const [selectedUsers, setSelectedUsers] = createSignal<any[]>([]);
const [selectedServers, setSelectedServers] = createSignal<any[]>([]);
const [onlineUsersCount, setOnlineUsersCount] = createSignal<
number | undefined
>();

const isServerSelected = (id: string) =>
selectedServers().find((s) => s.id === id);
Expand Down Expand Up @@ -388,6 +391,10 @@ function OnlineUsersPane() {
const [users, { mutate: setUsers }] =
createResource<ModerationUser[]>(getOnlineUsers);

createEffect(() => {
setOnlineUsersCount(users()?.length || undefined);
});

const [showAll, setShowAll] = createSignal(false);

const firstFive = () => users()?.slice(0, 5);
Expand Down Expand Up @@ -725,6 +732,10 @@ function StatsArea() {
title="Registered Users"
description={stats()?.totalRegisteredUsers?.toLocaleString()}
/>
<StatCard
title="Online Users"
description={onlineUsersCount()?.toLocaleString()}
/>
<StatCard
title="Messages"
description={stats()?.totalCreatedMessages?.toLocaleString()}
Expand Down

0 comments on commit d1bddf3

Please sign in to comment.