2019-10-29 07:20:54 +00:00
|
|
|
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);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-03 07:34:58 +00:00
|
|
|
export const refreshActionCableConnector = pubsubToken => {
|
|
|
|
window.chatwootPubsubToken = pubsubToken;
|
|
|
|
window.actionCable.disconnect();
|
|
|
|
window.actionCable = new ActionCableConnector(
|
|
|
|
window.WOOT_WIDGET,
|
|
|
|
window.chatwootPubsubToken
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2019-10-29 07:20:54 +00:00
|
|
|
export default ActionCableConnector;
|