Ensure that we have all conversations in redux store

This commit is contained in:
Scott Nonnenberg 2019-03-25 10:22:33 -07:00
parent d96b189a07
commit 0c69d725c3
2 changed files with 8 additions and 6 deletions

View File

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

View File

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