Merge branch 'develop' into feature/cw-3369
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { createConsumer } from '@rails/actioncable';
|
||||
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
||||
import { emitter } from 'shared/helpers/mitt';
|
||||
|
||||
const PRESENCE_INTERVAL = 20000;
|
||||
const RECONNECT_INTERVAL = 1000;
|
||||
@@ -28,7 +29,7 @@ class BaseActionCableConnector {
|
||||
this.onDisconnected();
|
||||
this.initReconnectTimer();
|
||||
// TODO: Remove this after completing the conversation list refetching
|
||||
window.bus.$emit(BUS_EVENTS.WEBSOCKET_DISCONNECT);
|
||||
emitter.emit(BUS_EVENTS.WEBSOCKET_DISCONNECT);
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import mitt from 'mitt';
|
||||
const emitter = mitt();
|
||||
export { emitter };
|
||||
@@ -0,0 +1,25 @@
|
||||
import { emitter } from '../mitt';
|
||||
|
||||
describe('emitter', () => {
|
||||
it('should emit and listen to events correctly', () => {
|
||||
const mockCallback = jest.fn();
|
||||
|
||||
// Subscribe to an event
|
||||
emitter.on('event', mockCallback);
|
||||
|
||||
// Emit the event
|
||||
emitter.emit('event', 'data');
|
||||
|
||||
// Expect the callback to be called with the correct data
|
||||
expect(mockCallback).toHaveBeenCalledWith('data');
|
||||
|
||||
// Unsubscribe from the event
|
||||
emitter.off('event', mockCallback);
|
||||
|
||||
// Emit the event again
|
||||
emitter.emit('event', 'data');
|
||||
|
||||
// Expect the callback not to be called again
|
||||
expect(mockCallback).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,9 @@
|
||||
import { emitter } from 'shared/helpers/mitt';
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
showAlert(message, action) {
|
||||
bus.$emit('newToastMessage', message, action);
|
||||
emitter.emit('newToastMessage', message, action);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -44,6 +44,9 @@ export default {
|
||||
whatsAppAPIProvider() {
|
||||
return this.inbox.provider || '';
|
||||
},
|
||||
isAMicrosoftInbox() {
|
||||
return this.isAnEmailChannel && this.inbox.provider === 'microsoft';
|
||||
},
|
||||
isAPIInbox() {
|
||||
return this.channelType === INBOX_TYPES.API;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user