mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-30 15:17:43 -05:00
Censor groups if own expired
This commit is contained in:
@@ -14,6 +14,7 @@ import { FULL_GROUP_SIZE } from "../q-constants";
|
||||
import type {
|
||||
DividedGroups,
|
||||
DividedGroupsUncensored,
|
||||
GroupExpiryStatus,
|
||||
LookingGroup,
|
||||
LookingGroupWithInviteCode,
|
||||
} from "../q-types";
|
||||
@@ -459,7 +460,7 @@ function resolveGroupSkill({
|
||||
|
||||
export function groupExpiryStatus(
|
||||
group?: Pick<Group, "latestActionAt">,
|
||||
): null | "EXPIRING_SOON" | "EXPIRED" {
|
||||
): null | GroupExpiryStatus {
|
||||
if (!group) return null;
|
||||
|
||||
// group expires in 30min without actions performed
|
||||
@@ -481,6 +482,22 @@ export function groupExpiryStatus(
|
||||
return null;
|
||||
}
|
||||
|
||||
export function censorGroupsIfOwnExpired({
|
||||
groups,
|
||||
ownGroupExpiryStatus,
|
||||
}: {
|
||||
groups: DividedGroups;
|
||||
ownGroupExpiryStatus: GroupExpiryStatus | null;
|
||||
}): DividedGroups {
|
||||
if (ownGroupExpiryStatus !== "EXPIRED") return groups;
|
||||
|
||||
return {
|
||||
own: groups.own,
|
||||
likesReceived: [],
|
||||
neutral: [],
|
||||
};
|
||||
}
|
||||
|
||||
const allTiersOrdered = TIERS.flatMap((tier) => [
|
||||
{ name: tier.name, isPlus: true },
|
||||
{ name: tier.name, isPlus: false },
|
||||
|
||||
@@ -69,3 +69,5 @@ export interface DividedGroupsUncensored {
|
||||
neutral: LookingGroupWithInviteCode[];
|
||||
likesReceived: LookingGroupWithInviteCode[];
|
||||
}
|
||||
|
||||
export type GroupExpiryStatus = "EXPIRING_SOON" | "EXPIRED";
|
||||
|
||||
@@ -55,6 +55,7 @@ import {
|
||||
addSkillRangeToGroups,
|
||||
addSkillsToGroups,
|
||||
censorGroups,
|
||||
censorGroupsIfOwnExpired,
|
||||
divideGroups,
|
||||
groupExpiryStatus,
|
||||
membersNeededForFull,
|
||||
@@ -502,8 +503,13 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
userId: user?.id,
|
||||
});
|
||||
|
||||
const expiryStatus = groupExpiryStatus(currentGroup);
|
||||
|
||||
return {
|
||||
groups: sortedGroups,
|
||||
groups: censorGroupsIfOwnExpired({
|
||||
groups: sortedGroups,
|
||||
ownGroupExpiryStatus: expiryStatus,
|
||||
}),
|
||||
role: currentGroup ? currentGroup.role : ("PREVIEWER" as const),
|
||||
chatCode: currentGroup?.chatCode,
|
||||
lastUpdated: new Date().getTime(),
|
||||
|
||||
Reference in New Issue
Block a user