diff --git a/embark-ui/src/actions/index.js b/embark-ui/src/actions/index.js index 7e6db2b5..7cc92cd2 100644 --- a/embark-ui/src/actions/index.js +++ b/embark-ui/src/actions/index.js @@ -113,7 +113,7 @@ export const messageSend = { export const MESSAGE_LISTEN = createRequestTypes('MESSAGE_LISTEN'); export const messageListen = { - request: (channel) => action(MESSAGE_LISTEN[REQUEST], {channel}), + request: (messageChannel) => action(MESSAGE_LISTEN[REQUEST], {messageChannels: [messageChannel]}), success: (messages) => action(MESSAGE_LISTEN[SUCCESS], {messages}), failure: (error) => action(MESSAGE_LISTEN[FAILURE], {error}) }; diff --git a/embark-ui/src/containers/CommunicationContainer.js b/embark-ui/src/containers/CommunicationContainer.js index 6f7e9699..389c23dc 100644 --- a/embark-ui/src/containers/CommunicationContainer.js +++ b/embark-ui/src/containers/CommunicationContainer.js @@ -5,7 +5,7 @@ import {Alert, Loader, Page} from 'tabler-react'; import {messageSend, messageListen, messageVersion} from "../actions"; import Communication from "../components/Communication"; import Loading from "../components/Loading"; -import {getMessageVersion, getMessages} from "../reducers/selectors"; +import {getMessageVersion, getMessages, getMessageChannels} from "../reducers/selectors"; class CommunicationContainer extends Component { componentDidMount() { @@ -40,7 +40,7 @@ class CommunicationContainer extends Component { this.listenToChannel(channel)} sendMessage={(channel, message) => this.sendMessage(channel, message)} channels={this.props.messages} - subscriptions={this.props.messages.subscriptions}/> + subscriptions={this.props.messageChannels}/> ); } @@ -51,12 +51,14 @@ CommunicationContainer.propTypes = { messageListen: PropTypes.func, communicationVersion: PropTypes.func, messageVersion: PropTypes.number, - messages: PropTypes.object + messages: PropTypes.object, + messageChannels: PropTypes.array }; function mapStateToProps(state) { return { messages: getMessages(state), + messageChannels: getMessageChannels(state), messageVersion: getMessageVersion(state) }; } diff --git a/embark-ui/src/reducers/index.js b/embark-ui/src/reducers/index.js index 16874698..e613daaa 100644 --- a/embark-ui/src/reducers/index.js +++ b/embark-ui/src/reducers/index.js @@ -13,7 +13,7 @@ const entitiesDefaultState = { contractProfiles: [], commands: [], messages: [], - subscriptions: [], + messageChannels: [], messageVersion: null }; diff --git a/embark-ui/src/reducers/selectors.js b/embark-ui/src/reducers/selectors.js index 0b79c5cc..bac61e4b 100644 --- a/embark-ui/src/reducers/selectors.js +++ b/embark-ui/src/reducers/selectors.js @@ -62,6 +62,10 @@ export function getMessageVersion(state) { return state.entities.messageVersion; } +export function getMessageChannels(state) { + return state.entities.messageChannels; +} + export function getMessages(state) { const messages = {}; state.entities.messages.forEach(message => { diff --git a/embark-ui/src/sagas/index.js b/embark-ui/src/sagas/index.js index c8edfb17..6929c0c5 100644 --- a/embark-ui/src/sagas/index.js +++ b/embark-ui/src/sagas/index.js @@ -121,11 +121,11 @@ export function *watchSendMessage() { } export function *listenToMessages(action) { - const socket = api.listenToChannel(action.channel); + const socket = api.listenToChannel(action.messageChannels[0]); const channel = yield call(createChannel, socket); while (true) { const message = yield take(channel); - yield put(messageListen.success([{channel: action.channel, message: message.data, time: message.time}])); + yield put(messageListen.success([{channel: action.messageChannels[0], message: message.data, time: message.time}])); } }