remove contactCollection in convos.

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

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

@ -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';

@ -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()

@ -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',

@ -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<Props> {
};
public editProfileHandle() {
window.showEditProfileDialog(noop);
window.showEditProfileDialog();
}
public render(): JSX.Element {
@ -161,7 +160,7 @@ class ActionsPanelPrivate extends React.Component<Props> {
<div className="module-left-pane__sections-container">
<this.Section
type={SectionType.Profile}
avatarPath={this.props.ourPrimaryConversation?.avatarPath}
avatarPath={this.props.ourPrimaryConversation.avatarPath}
isSelected={isProfilePageSelected}
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
// 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

Loading…
Cancel
Save