Ensure that we have all conversations in redux store

pull/272/head
Scott Nonnenberg 6 years ago
parent d96b189a07
commit 0c69d725c3

@ -55,6 +55,7 @@
}))(); }))();
window.getInboxCollection = () => inboxCollection; window.getInboxCollection = () => inboxCollection;
window.getConversations = () => conversations;
window.ConversationController = { window.ConversationController = {
get(id) { get(id) {

@ -1,6 +1,7 @@
/* global /* global
ConversationController, ConversationController,
extension, extension,
getConversations,
getInboxCollection, getInboxCollection,
i18n, i18n,
Whisper, Whisper,
@ -104,8 +105,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
); );
const initialState = { const initialState = {
@ -145,19 +146,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