Ensure that we have all conversations in redux store

pull/272/head
Scott Nonnenberg 6 years ago committed by Mikunj
parent 7387e88c97
commit ef670bec3f

@ -57,6 +57,7 @@
}))(); }))();
window.getInboxCollection = () => inboxCollection; window.getInboxCollection = () => inboxCollection;
window.getConversations = () => conversations;
const contactCollection = new (Backbone.Collection.extend({ const contactCollection = new (Backbone.Collection.extend({
initialize() { initialize() {

@ -1,5 +1,6 @@
/* global /* global
extension, extension,
getConversations,
getInboxCollection, getInboxCollection,
i18n, i18n,
Whisper, Whisper,
@ -137,8 +138,8 @@
}, },
setupLeftPane() { setupLeftPane() {
// Here we set up a full redux store with initial state for our LeftPane Root // Here we set up a full redux store with initial state for our LeftPane Root
const inboxCollection = getInboxCollection(); const convoCollection = getConversations();
const conversations = inboxCollection.map( const conversations = convoCollection.map(
conversation => conversation.cachedProps conversation => conversation.cachedProps
); );
@ -180,19 +181,19 @@
this.openConversationAction = openConversationExternal; this.openConversationAction = openConversationExternal;
this.listenTo(inboxCollection, 'remove', conversation => { this.listenTo(convoCollection, 'remove', conversation => {
const { id } = conversation || {}; const { id } = conversation || {};
conversationRemoved(id); conversationRemoved(id);
}); });
this.listenTo(inboxCollection, 'add', conversation => { this.listenTo(convoCollection, 'add', conversation => {
const { id, cachedProps } = conversation || {}; const { id, cachedProps } = conversation || {};
conversationAdded(id, cachedProps); conversationAdded(id, cachedProps);
}); });
this.listenTo(inboxCollection, 'change', conversation => { this.listenTo(convoCollection, 'change', conversation => {
const { id, cachedProps } = conversation || {}; const { id, cachedProps } = conversation || {};
conversationChanged(id, cachedProps); conversationChanged(id, cachedProps);
}); });
this.listenTo(inboxCollection, 'reset', removeAllConversations); this.listenTo(convoCollection, 'reset', removeAllConversations);
Whisper.events.on('messageExpired', messageExpired); Whisper.events.on('messageExpired', messageExpired);
Whisper.events.on('userChanged', userChanged); Whisper.events.on('userChanged', userChanged);

Loading…
Cancel
Save