Chatwoot/app/javascript/widget/helpers/actionCable.js

26 lines
683 B
JavaScript
Raw Normal View History

import BaseActionCableConnector from '../../shared/helpers/BaseActionCableConnector';
class ActionCableConnector extends BaseActionCableConnector {
constructor(app, pubsubToken) {
super(app, pubsubToken);
this.events = {
'message.created': this.onMessageCreated,
};
}
onMessageCreated = data => {
this.app.$store.dispatch('conversation/addMessage', data);
};
}
export const refreshActionCableConnector = pubsubToken => {
window.chatwootPubsubToken = pubsubToken;
window.actionCable.disconnect();
window.actionCable = new ActionCableConnector(
window.WOOT_WIDGET,
window.chatwootPubsubToken
);
};
export default ActionCableConnector;