Show members: Pull conversation from group table

This commit is contained in:
Scott Nonnenberg 2019-02-11 14:52:58 -08:00
parent 12739ac82d
commit 462fa712bc
4 changed files with 27 additions and 14 deletions

View file

@ -636,7 +636,7 @@ async function getAllGroupIds() {
return map(rows, row => row.id); return map(rows, row => row.id);
} }
async function getAllGroups() { async function getAllGroups() {
const rows = await db.all('SELECT id FROM groups ORDER BY id ASC;'); const rows = await db.all('SELECT json FROM groups ORDER BY id ASC;');
return map(rows, row => jsonToObject(row.json)); return map(rows, row => jsonToObject(row.json));
} }
async function bulkAddGroups(array) { async function bulkAddGroups(array) {

View file

@ -74,6 +74,17 @@
this.trigger('messageError', message, errors); this.trigger('messageError', message, errors);
}, },
getContactCollection() {
const collection = new Backbone.Collection();
const collator = new Intl.Collator();
collection.comparator = (left, right) => {
const leftLower = left.getTitle().toLowerCase();
const rightLower = right.getTitle().toLowerCase();
return collator.compare(leftLower, rightLower);
};
return collection;
},
initialize() { initialize() {
this.ourNumber = textsecure.storage.user.getNumber(); this.ourNumber = textsecure.storage.user.getNumber();
this.verifiedEnum = textsecure.storage.protocol.VerifiedStatus; this.verifiedEnum = textsecure.storage.protocol.VerifiedStatus;
@ -82,13 +93,7 @@
// our first save to the database. Or first fetch from the database. // our first save to the database. Or first fetch from the database.
this.initialPromise = Promise.resolve(); this.initialPromise = Promise.resolve();
this.contactCollection = new Backbone.Collection(); this.contactCollection = this.getContactCollection();
const collator = new Intl.Collator();
this.contactCollection.comparator = (left, right) => {
const leftLower = left.getTitle().toLowerCase();
const rightLower = right.getTitle().toLowerCase();
return collator.compare(leftLower, rightLower);
};
this.messageCollection = new Whisper.MessageCollection([], { this.messageCollection = new Whisper.MessageCollection([], {
conversation: this, conversation: this,
}); });

View file

@ -633,7 +633,7 @@
// back to the conversation's current recipients // back to the conversation's current recipients
const phoneNumbers = this.isIncoming() const phoneNumbers = this.isIncoming()
? [this.get('source')] ? [this.get('source')]
: this.get('recipients') || this.conversation.getRecipients(); : this.get('sent_to') || this.conversation.getRecipients();
// This will make the error message for outgoing key errors a bit nicer // This will make the error message for outgoing key errors a bit nicer
const allErrors = (this.get('errors') || []).map(error => { const allErrors = (this.get('errors') || []).map(error => {

View file

@ -209,8 +209,8 @@
await this.showAllMedia(); await this.showAllMedia();
this.updateHeader(); this.updateHeader();
}, },
onShowGroupMembers: () => { onShowGroupMembers: async () => {
this.showMembers(); await this.showMembers();
this.updateHeader(); this.updateHeader();
}, },
onGoBack: () => { onGoBack: () => {
@ -1127,13 +1127,21 @@
} }
}, },
showMembers(e, providedMembers, options = {}) { async showMembers(e, providedMembers, options = {}) {
_.defaults(options, { needVerify: false }); _.defaults(options, { needVerify: false });
const members = providedMembers || this.model.contactCollection; const fromConversation = this.model.isPrivate()
? [this.model.id]
: await textsecure.storage.groups.getNumbers(this.model.id);
const members =
providedMembers ||
fromConversation.map(id => ConversationController.get(id));
const model = this.model.getContactCollection();
model.reset(members);
const view = new Whisper.GroupMemberList({ const view = new Whisper.GroupMemberList({
model: members, model,
// we pass this in to allow nested panels // we pass this in to allow nested panels
listenBack: this.listenBack.bind(this), listenBack: this.listenBack.bind(this),
needVerify: options.needVerify, needVerify: options.needVerify,