mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
Fix SQ preview showing groups not actually looking
This commit is contained in:
parent
44d508c647
commit
a69b0904ce
|
|
@ -239,6 +239,7 @@ class SendouQClass {
|
|||
) {
|
||||
const usersTier = this.#getUserTier(userId);
|
||||
return this.groups
|
||||
.filter((group) => this.#isSuitableLookingGroup({ group }))
|
||||
.map(this.#getAddMemberPrivateNoteMapper(notes))
|
||||
.sort(this.#getSkillAndNoteSortComparator(usersTier))
|
||||
.map((group) => this.#addPreviewTierRange(group))
|
||||
|
|
@ -269,18 +270,14 @@ class SendouQClass {
|
|||
? [1, 2]
|
||||
: [1, 2, 3];
|
||||
|
||||
const staleThreshold = sub(new Date(), { seconds: SECONDS_TILL_STALE });
|
||||
return this.groups
|
||||
.filter((group) => {
|
||||
const groupLastAction = databaseTimestampToDate(group.latestActionAt);
|
||||
return (
|
||||
group.status === "ACTIVE" &&
|
||||
!group.matchId &&
|
||||
group.id !== ownGroup.id &&
|
||||
currentMemberCountOptions.includes(group.members.length) &&
|
||||
groupLastAction >= staleThreshold
|
||||
);
|
||||
})
|
||||
.filter((group) =>
|
||||
this.#isSuitableLookingGroup({
|
||||
group,
|
||||
ownGroupId: ownGroup.id,
|
||||
currentMemberCountOptions,
|
||||
}),
|
||||
)
|
||||
.map(this.#getGroupReplayMapper(userId))
|
||||
.map(this.#getAddTierRangeMapper(ownGroup.tier))
|
||||
.map(this.#getAddMemberPrivateNoteMapper(notes))
|
||||
|
|
@ -538,6 +535,30 @@ class SendouQClass {
|
|||
) ?? { isPlus: false, name: "IRON" }
|
||||
);
|
||||
}
|
||||
|
||||
#isSuitableLookingGroup({
|
||||
group,
|
||||
ownGroupId,
|
||||
currentMemberCountOptions,
|
||||
}: {
|
||||
group: SendouQClass["groups"][number];
|
||||
ownGroupId?: number;
|
||||
currentMemberCountOptions?: number[];
|
||||
}) {
|
||||
if (group.status !== "ACTIVE") return false;
|
||||
if (group.matchId) return false;
|
||||
if (group.id === ownGroupId) return false;
|
||||
if (
|
||||
currentMemberCountOptions &&
|
||||
!currentMemberCountOptions.includes(group.members.length)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const staleThreshold = sub(new Date(), { seconds: SECONDS_TILL_STALE });
|
||||
const groupLastAction = databaseTimestampToDate(group.latestActionAt);
|
||||
return groupLastAction >= staleThreshold;
|
||||
}
|
||||
}
|
||||
|
||||
const groups = await SQGroupRepository.findCurrentGroups();
|
||||
|
|
|
|||
|
|
@ -19,10 +19,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|||
SendouQ.usersInQueue,
|
||||
);
|
||||
|
||||
const groups = isPreview
|
||||
? SendouQ.previewGroups(user.id, privateNotes)
|
||||
: SendouQ.lookingGroups(user.id, privateNotes);
|
||||
const ownGroup = SendouQ.findOwnGroup(user.id);
|
||||
const groups =
|
||||
isPreview && !ownGroup
|
||||
? SendouQ.previewGroups(user.id, privateNotes)
|
||||
: SendouQ.lookingGroups(user.id, privateNotes);
|
||||
|
||||
if (!isPreview) {
|
||||
sqRedirectIfNeeded({
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user