fix subscriptions, now called messageChannels
This commit is contained in:
parent
a52bbcac05
commit
5d126c8caa
|
@ -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})
|
||||
};
|
||||
|
|
|
@ -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 {
|
|||
<Communication listenToMessages={(channel) => this.listenToChannel(channel)}
|
||||
sendMessage={(channel, message) => this.sendMessage(channel, message)}
|
||||
channels={this.props.messages}
|
||||
subscriptions={this.props.messages.subscriptions}/>
|
||||
subscriptions={this.props.messageChannels}/>
|
||||
</Page.Content>
|
||||
);
|
||||
}
|
||||
|
@ -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)
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ const entitiesDefaultState = {
|
|||
contractProfiles: [],
|
||||
commands: [],
|
||||
messages: [],
|
||||
subscriptions: [],
|
||||
messageChannels: [],
|
||||
messageVersion: null
|
||||
};
|
||||
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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}]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue