b0950d6880
Co-authored-by: Pranav Raj S <pranavrajs@gmail.com> Co-authored-by: Nithin David Thomas <webofnithin@gmail.com>
28 lines
721 B
JavaScript
28 lines
721 B
JavaScript
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 => {
|
|
if (!pubsubToken) {
|
|
return;
|
|
}
|
|
window.chatwootPubsubToken = pubsubToken;
|
|
window.actionCable.disconnect();
|
|
window.actionCable = new ActionCableConnector(
|
|
window.WOOT_WIDGET,
|
|
window.chatwootPubsubToken
|
|
);
|
|
};
|
|
|
|
export default ActionCableConnector;
|