diff --git a/app/sql.js b/app/sql.js index 5fa40c595b..52901f663a 100644 --- a/app/sql.js +++ b/app/sql.js @@ -636,7 +636,7 @@ async function getAllGroupIds() { return map(rows, row => row.id); } 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)); } async function bulkAddGroups(array) { diff --git a/js/models/conversations.js b/js/models/conversations.js index afde991fe3..e1dc3f8ee7 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -74,6 +74,17 @@ 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() { this.ourNumber = textsecure.storage.user.getNumber(); this.verifiedEnum = textsecure.storage.protocol.VerifiedStatus; @@ -82,13 +93,7 @@ // our first save to the database. Or first fetch from the database. this.initialPromise = Promise.resolve(); - this.contactCollection = new Backbone.Collection(); - 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.contactCollection = this.getContactCollection(); this.messageCollection = new Whisper.MessageCollection([], { conversation: this, }); diff --git a/js/models/messages.js b/js/models/messages.js index 66fbe5e78b..36f2a2c644 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -633,7 +633,7 @@ // back to the conversation's current recipients const phoneNumbers = this.isIncoming() ? [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 const allErrors = (this.get('errors') || []).map(error => { diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 3d2aafb560..a0ba2c5fb5 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -209,8 +209,8 @@ await this.showAllMedia(); this.updateHeader(); }, - onShowGroupMembers: () => { - this.showMembers(); + onShowGroupMembers: async () => { + await this.showMembers(); this.updateHeader(); }, onGoBack: () => { @@ -1127,13 +1127,21 @@ } }, - showMembers(e, providedMembers, options = {}) { + async showMembers(e, providedMembers, options = {}) { _.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({ - model: members, + model, // we pass this in to allow nested panels listenBack: this.listenBack.bind(this), needVerify: options.needVerify,