updateSharedGroups: Make one database query, check for membership, sort
This commit is contained in:
parent
fc3ebe40a7
commit
7d397167cd
1 changed files with 12 additions and 5 deletions
|
@ -4590,16 +4590,23 @@ export class ConversationModel extends window.Backbone
|
|||
}
|
||||
|
||||
const ourUuid = window.textsecure.storage.user.getCheckedUuid();
|
||||
const ourGroups =
|
||||
await window.ConversationController.getAllGroupsInvolvingUuid(ourUuid);
|
||||
const theirUuid = this.getUuid();
|
||||
if (!theirUuid) {
|
||||
return;
|
||||
}
|
||||
const theirGroups =
|
||||
await window.ConversationController.getAllGroupsInvolvingUuid(theirUuid);
|
||||
|
||||
const sharedGroups = window._.intersection(ourGroups, theirGroups);
|
||||
const ourGroups =
|
||||
await window.ConversationController.getAllGroupsInvolvingUuid(ourUuid);
|
||||
const sharedGroups = ourGroups
|
||||
.filter(
|
||||
c =>
|
||||
c.hasMember(ourUuid.toString()) && c.hasMember(theirUuid.toString())
|
||||
)
|
||||
.sort(
|
||||
(left, right) =>
|
||||
(right.get('timestamp') || 0) - (left.get('timestamp') || 0)
|
||||
);
|
||||
|
||||
const sharedGroupNames = sharedGroups.map(conversation =>
|
||||
conversation.getTitle()
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue