remove contactCollection in convos.

pull/1459/head
Audric Ackermann 4 years ago
parent a6cecd33e3
commit b218611831

@ -618,6 +618,7 @@
displayName: newName, displayName: newName,
avatar: newAvatarPath, avatar: newAvatarPath,
}); });
conversation.commit();
} catch (error) { } catch (error) {
window.log.error( window.log.error(
'showEditProfileDialog Error ensuring that image is properly sized:', 'showEditProfileDialog Error ensuring that image is properly sized:',

@ -51,17 +51,6 @@
return `group(${this.id})`; 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() { initialize() {
this.ourNumber = textsecure.storage.user.getNumber(); this.ourNumber = textsecure.storage.user.getNumber();
@ -833,21 +822,10 @@
// We're offline! // We're offline!
if (!textsecure.messaging) { if (!textsecure.messaging) {
let errors; const error = new Error('Network is not available');
if (this.contactCollection.length) { error.name = 'SendMessageNetworkError';
errors = this.contactCollection.map(contact => { error.number = this.id;
const error = new Error('Network is not available'); await message.saveErrors([error]);
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);
return null; return null;
} }
@ -1400,20 +1378,6 @@
hasMember(number) { hasMember(number) {
return _.contains(this.get('members'), 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 // returns true if this is a closed/medium or open group
isGroup() { isGroup() {
return this.get('type') === 'group'; return this.get('type') === 'group';

@ -1385,25 +1385,6 @@
await this.commit(); 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) { async markMessageSyncOnly(dataMessage) {
this.set({ this.set({
// These are the same as a normal send() // These are the same as a normal send()

@ -42,29 +42,6 @@ describe('ConversationCollection', () => {
// // await message.commit(false); // // await message.commit(false);
// }); // });
// after(clearDatabase); // 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 () => { // it('contains its own messages', async () => {
// const convo = new Whisper.ConversationCollection().add({ // const convo = new Whisper.ConversationCollection().add({
// id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab', // id: '051d11d01e56d9bfc3d74115c33225a632321b509ac17a13fdeac71165d09b94ab',

@ -7,7 +7,6 @@ import { darkTheme, lightTheme } from '../../state/ducks/SessionTheme';
import { SessionToastContainer } from './SessionToastContainer'; import { SessionToastContainer } from './SessionToastContainer';
import { mapDispatchToProps } from '../../state/actions'; import { mapDispatchToProps } from '../../state/actions';
import { ConversationType } from '../../state/ducks/conversations'; import { ConversationType } from '../../state/ducks/conversations';
import { noop } from 'lodash';
import { DefaultTheme } from 'styled-components'; import { DefaultTheme } from 'styled-components';
import { StateType } from '../../state/reducer'; import { StateType } from '../../state/reducer';
import { ConversationController } from '../../session/conversations'; import { ConversationController } from '../../session/conversations';
@ -145,7 +144,7 @@ class ActionsPanelPrivate extends React.Component<Props> {
}; };
public editProfileHandle() { public editProfileHandle() {
window.showEditProfileDialog(noop); window.showEditProfileDialog();
} }
public render(): JSX.Element { public render(): JSX.Element {
@ -161,7 +160,7 @@ class ActionsPanelPrivate extends React.Component<Props> {
<div className="module-left-pane__sections-container"> <div className="module-left-pane__sections-container">
<this.Section <this.Section
type={SectionType.Profile} type={SectionType.Profile}
avatarPath={this.props.ourPrimaryConversation?.avatarPath} avatarPath={this.props.ourPrimaryConversation.avatarPath}
isSelected={isProfilePageSelected} isSelected={isProfilePageSelected}
onSelect={this.handleSectionSelect} onSelect={this.handleSectionSelect}
/> />

@ -537,14 +537,15 @@ export async function handleMessageJob(
// Note that this can save the message again, if jobs were queued. We need to // 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 // call it after we have an id for this message, because the jobs refer back
// to their source message. // to their source message.
await queueAttachmentDownloads(message); await queueAttachmentDownloads(message);
// this is
const unreadCount = await conversation.getUnreadCount(); const unreadCount = await conversation.getUnreadCount();
conversation.set({ unreadCount }); conversation.set({ unreadCount });
// this is a throttled call and will only run once every 1 sec
conversation.updateLastMessage();
await conversation.commit(); await conversation.commit();
conversation.trigger('newmessage', message);
try { try {
// We go to the database here because, between the message save above and // 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 // the previous line's trigger() call, we might have marked all messages
@ -555,6 +556,7 @@ export async function handleMessageJob(
Message: Whisper.Message, Message: Whisper.Message,
} }
); );
const previousUnread = message.get('unread'); const previousUnread = message.get('unread');
// Important to update message with latest read state from database // Important to update message with latest read state from database

Loading…
Cancel
Save