Search view now works with deleting contacts as well

pull/252/head
Beaudan 7 years ago
parent df93c97b48
commit 5c29c6cb1d

@ -115,6 +115,9 @@
window.getContactCollection = () => contactCollection; window.getContactCollection = () => contactCollection;
window.ConversationController = { window.ConversationController = {
getCollection() {
return conversations;
},
markAsSelected(toSelect) { markAsSelected(toSelect) {
conversations.each(conversation => { conversations.each(conversation => {
const current = conversation.isSelected || false; const current = conversation.isSelected || false;
@ -209,17 +212,11 @@
return conversation; return conversation;
}, },
async deleteContact(id, type) { async deleteContact(id) {
if (typeof id !== 'string') { if (typeof id !== 'string') {
throw new TypeError("'id' must be a string"); throw new TypeError("'id' must be a string");
} }
if (type !== 'private' && type !== 'group') {
throw new TypeError(
`'type' must be 'private' or 'group'; got: '${type}'`
);
}
if (!this._initialFetchComplete) { if (!this._initialFetchComplete) {
throw new Error( throw new Error(
'ConversationController.get() needs complete initial fetch' 'ConversationController.get() needs complete initial fetch'
@ -230,7 +227,6 @@
if (!conversation) { if (!conversation) {
return; return;
} }
conversations.remove(conversation);
await conversation.destroyMessages(); await conversation.destroyMessages();
const deviceIds = await textsecure.storage.protocol.getDeviceIds(id); const deviceIds = await textsecure.storage.protocol.getDeviceIds(id);
await Promise.all( await Promise.all(
@ -246,6 +242,7 @@
await window.Signal.Data.removeConversation(id, { await window.Signal.Data.removeConversation(id, {
Conversation: Whisper.Conversation, Conversation: Whisper.Conversation,
}); });
conversations.remove(conversation);
}, },
getOrCreateAndWait(id, type) { getOrCreateAndWait(id, type) {
return this._initialPromise.then(() => { return this._initialPromise.then(() => {

@ -32,11 +32,7 @@
onDeleteContact: () => { onDeleteContact: () => {
Whisper.events.trigger('showConfirmationDialog', { Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deleteContactConfirmation'), message: i18n('deleteContactConfirmation'),
onOk: () => onOk: () => ConversationController.deleteContact(this.model.id),
ConversationController.deleteContact(
this.model.id,
this.model.get('type')
),
}); });
}, },
onDeleteMessages: () => { onDeleteMessages: () => {

@ -1452,10 +1452,7 @@
Whisper.events.trigger('showConfirmationDialog', { Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deleteContactConfirmation'), message: i18n('deleteContactConfirmation'),
onOk: () => { onOk: () => {
ConversationController.deleteContact( ConversationController.deleteContact(this.model.id);
this.model.id,
this.model.get('type')
);
this.remove(); this.remove();
}, },
}); });

@ -180,6 +180,12 @@
input: this.$('input.search'), input: this.$('input.search'),
}); });
this.searchView.listenTo(
ConversationController.getCollection(),
'remove',
this.searchView.filterContacts
);
this.searchView.$el.hide(); this.searchView.$el.hide();
this.listenTo(this.searchView, 'hide', function toggleVisibility() { this.listenTo(this.searchView, 'hide', function toggleVisibility() {

Loading…
Cancel
Save