mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-19 01:37:49 -05:00
34 lines
923 B
TypeScript
34 lines
923 B
TypeScript
import { groupExpiryStatus } from "~/features/sendouq/core/groups";
|
|
import { SendouQ } from "~/features/sendouq/core/SendouQ.server";
|
|
import { FULL_GROUP_SIZE } from "~/features/sendouq/q-constants";
|
|
import { SENDOUQ_ACTIVITY_LABEL } from "./friends-constants";
|
|
|
|
export function resolveFriendActivity(
|
|
friendId: number,
|
|
tournamentName: string | null,
|
|
teamMemberCount: number | null,
|
|
tournamentMinTeamSize: number | null,
|
|
) {
|
|
const ownGroup = SendouQ.findOwnGroup(friendId);
|
|
|
|
if (
|
|
ownGroup &&
|
|
ownGroup.members.length < FULL_GROUP_SIZE &&
|
|
groupExpiryStatus(ownGroup.latestActionAt) !== "EXPIRED"
|
|
) {
|
|
return {
|
|
subtitle: SENDOUQ_ACTIVITY_LABEL,
|
|
badge: `${ownGroup.members.length}/${FULL_GROUP_SIZE}`,
|
|
};
|
|
}
|
|
|
|
if (tournamentName) {
|
|
return {
|
|
subtitle: tournamentName,
|
|
badge: `${teamMemberCount ?? 1}/${tournamentMinTeamSize ?? FULL_GROUP_SIZE}`,
|
|
};
|
|
}
|
|
|
|
return { subtitle: null, badge: null };
|
|
}
|