diff --git a/ts/receiver/closedGroups.ts b/ts/receiver/closedGroups.ts index 4f5d12dd9..1bebd4e7d 100644 --- a/ts/receiver/closedGroups.ts +++ b/ts/receiver/closedGroups.ts @@ -196,16 +196,19 @@ async function handleNewClosedGroup( 'incoming' ); - convo.set('name', name); - convo.set('members', members); - // mark a closed group as a medium group. - // this field is used to poll for this groupPubKey on the swarm nodes, among other things - convo.set('is_medium_group', true); - convo.set('active_at', Date.now()); - convo.set('lastJoinedTimestamp', Date.now()); - // We only set group admins on group creation - convo.set('groupAdmins', admins); + const groupDetails = { + id: groupId, + name: name, + members: members, + admins, + active: true, + }; + + // be sure to call this before sending the message. + // the sending pipeline needs to know from GroupUtils when a message is for a medium group + await ClosedGroup.updateOrCreateClosedGroup(groupDetails); + await convo.commit(); // sanity checks validate this // tslint:disable: no-non-null-assertion @@ -732,8 +735,6 @@ export async function createClosedGroup( // be sure to call this before sending the message. // the sending pipeline needs to know from GroupUtils when a message is for a medium group await ClosedGroup.updateOrCreateClosedGroup(groupDetails); - convo.set('lastJoinedTimestamp', Date.now()); - convo.set('active_at', Date.now()); await convo.commit(); convo.updateLastMessage(); diff --git a/ts/session/group/index.ts b/ts/session/group/index.ts index 088fb4a24..b2c2b058b 100644 --- a/ts/session/group/index.ts +++ b/ts/session/group/index.ts @@ -258,8 +258,11 @@ export async function updateOrCreateClosedGroup(details: GroupInfo) { // activeAt is null, then this group has been purposefully hidden. if (activeAt !== null) { updates.active_at = activeAt || Date.now(); + updates.timestamp = updates.active_at; } updates.left = false; + updates.lastJoinedTimestamp = updates.active_at; + } else { updates.left = true; }