From be63db096e1e307014cc8f17a5f68a0b09cc9864 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 27 Mar 2022 14:59:44 +0300 Subject: [PATCH] United groups to the top Closes #768 --- app/models/LFGGroup.server.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/LFGGroup.server.ts b/app/models/LFGGroup.server.ts index 1aef3bc4f..fd5d4c5b9 100644 --- a/app/models/LFGGroup.server.ts +++ b/app/models/LFGGroup.server.ts @@ -138,13 +138,17 @@ export function uniteGroups({ removeCaptainsFromOther, unitedGroupIsRanked, }: UniteGroupsArgs) { + const survivingGroupUpdatedTimestamps = { + lastActionAt: new Date(), + createdAt: new Date(), + }; + return db.$transaction([ db.lfgGroupMember.updateMany({ where: { groupId: otherGroupId }, data: { groupId: survivingGroupId, captain: removeCaptainsFromOther ? false : undefined, - // TODO: also reset message }, }), db.lfgGroup.delete({ where: { id: otherGroupId } }), @@ -157,8 +161,8 @@ export function uniteGroups({ where: { id: survivingGroupId }, data: typeof unitedGroupIsRanked === "boolean" - ? { ranked: unitedGroupIsRanked, lastActionAt: new Date() } - : { lastActionAt: new Date() }, + ? { ranked: unitedGroupIsRanked, ...survivingGroupUpdatedTimestamps } + : survivingGroupUpdatedTimestamps, }), ]); }