diff --git a/js/background.js b/js/background.js index 47fc03cbc..03ae85848 100644 --- a/js/background.js +++ b/js/background.js @@ -618,6 +618,7 @@ displayName: newName, avatar: newAvatarPath, }); + conversation.commit(); } catch (error) { window.log.error( 'showEditProfileDialog Error ensuring that image is properly sized:', diff --git a/js/models/conversations.js b/js/models/conversations.js index 03b009bfe..35a150cc8 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -51,17 +51,6 @@ return `group(${this.id})`; }, - 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(); @@ -833,21 +822,10 @@ // We're offline! if (!textsecure.messaging) { - let errors; - if (this.contactCollection.length) { - errors = this.contactCollection.map(contact => { - const error = new Error('Network is not available'); - error.name = 'SendMessageNetworkError'; - error.number = contact.id; - return error; - }); - } else { - const error = new Error('Network is not available'); - error.name = 'SendMessageNetworkError'; - error.number = this.id; - errors = [error]; - } - await message.saveErrors(errors); + const error = new Error('Network is not available'); + error.name = 'SendMessageNetworkError'; + error.number = this.id; + await message.saveErrors([error]); return null; } @@ -1400,20 +1378,6 @@ hasMember(number) { return _.contains(this.get('members'), number); }, - fetchContacts() { - if (this.isPrivate()) { - this.contactCollection.reset([this]); - return Promise.resolve(); - } - const members = this.get('members') || []; - const promises = members.map(number => - window.getConversationController().getOrCreateAndWait(number, 'private') - ); - - return Promise.all(promises).then(contacts => { - this.contactCollection.reset(contacts); - }); - }, // returns true if this is a closed/medium or open group isGroup() { return this.get('type') === 'group'; diff --git a/js/models/messages.js b/js/models/messages.js index 386d15974..9ccfd2c61 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -1385,25 +1385,6 @@ await this.commit(); }, - someRecipientsFailed() { - const c = this.getConversation(); - if (!c || c.isPrivate()) { - return false; - } - - const recipients = c.contactCollection.length - 1; - const errors = this.get('errors'); - if (!errors) { - return false; - } - - if (errors.length > 0 && recipients > 0 && errors.length < recipients) { - return true; - } - - return false; - }, - async markMessageSyncOnly(dataMessage) { this.set({ // These are the same as a normal send() diff --git a/test/models/conversations_test.js b/test/models/conversations_test.js index e9d59c37d..080f2c1bb 100644 --- a/test/models/conversations_test.js +++ b/test/models/conversations_test.js @@ -42,29 +42,6 @@ describe('ConversationCollection', () => { // // await message.commit(false); // }); // after(clearDatabase); - // it('sorts its contacts in an intl-friendly way', () => { - // const convo = new Whisper.Conversation({ - // id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab', - // }); - // convo.contactCollection.add( - // new Whisper.Conversation({ - // name: 'C', - // }) - // ); - // convo.contactCollection.add( - // new Whisper.Conversation({ - // name: 'B', - // }) - // ); - // convo.contactCollection.add( - // new Whisper.Conversation({ - // name: 'Á', - // }) - // ); - // assert.strictEqual(convo.contactCollection.at('0').get('name'), 'Á'); - // assert.strictEqual(convo.contactCollection.at('1').get('name'), 'B'); - // assert.strictEqual(convo.contactCollection.at('2').get('name'), 'C'); - // }); // it('contains its own messages', async () => { // const convo = new Whisper.ConversationCollection().add({ // id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab', diff --git a/ts/components/session/ActionsPanel.tsx b/ts/components/session/ActionsPanel.tsx index 4f1ae9c43..eec18a63f 100644 --- a/ts/components/session/ActionsPanel.tsx +++ b/ts/components/session/ActionsPanel.tsx @@ -7,7 +7,6 @@ import { darkTheme, lightTheme } from '../../state/ducks/SessionTheme'; import { SessionToastContainer } from './SessionToastContainer'; import { mapDispatchToProps } from '../../state/actions'; import { ConversationType } from '../../state/ducks/conversations'; -import { noop } from 'lodash'; import { DefaultTheme } from 'styled-components'; import { StateType } from '../../state/reducer'; import { ConversationController } from '../../session/conversations'; @@ -145,7 +144,7 @@ class ActionsPanelPrivate extends React.Component { }; public editProfileHandle() { - window.showEditProfileDialog(noop); + window.showEditProfileDialog(); } public render(): JSX.Element { @@ -161,7 +160,7 @@ class ActionsPanelPrivate extends React.Component {
diff --git a/ts/receiver/queuedJob.ts b/ts/receiver/queuedJob.ts index d9b8f16f2..39d2ece42 100644 --- a/ts/receiver/queuedJob.ts +++ b/ts/receiver/queuedJob.ts @@ -537,14 +537,15 @@ export async function handleMessageJob( // Note that this can save the message again, if jobs were queued. We need to // call it after we have an id for this message, because the jobs refer back // to their source message. + await queueAttachmentDownloads(message); - // this is + const unreadCount = await conversation.getUnreadCount(); conversation.set({ unreadCount }); + // this is a throttled call and will only run once every 1 sec + conversation.updateLastMessage(); await conversation.commit(); - conversation.trigger('newmessage', message); - try { // We go to the database here because, between the message save above and // the previous line's trigger() call, we might have marked all messages @@ -555,6 +556,7 @@ export async function handleMessageJob( Message: Whisper.Message, } ); + const previousUnread = message.get('unread'); // Important to update message with latest read state from database