fix order of added new group in leftPane

This commit is contained in:
Audric Ackermann 2021-02-01 13:12:44 +11:00
parent 3b3378a2ee
commit ebd94ce15c
No known key found for this signature in database
GPG key ID: 999F434D76324AD4
2 changed files with 15 additions and 11 deletions

View file

@ -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();

View file

@ -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;
}