feat(whatsapp): add calling enable/disable toggle in inbox settings UI

This commit is contained in:
Tanmay Deep Sharma
2026-03-06 10:09:53 +05:30
parent fd69b4c8f2
commit f849cbb76a
23 changed files with 1145 additions and 4 deletions
@@ -4,6 +4,7 @@ import DashboardAudioNotificationHelper from './AudioAlerts/DashboardAudioNotifi
import { BUS_EVENTS } from 'shared/constants/busEvents';
import { emitter } from 'shared/helpers/mitt';
import { useImpersonation } from 'dashboard/composables/useImpersonation';
import { useWhatsappCallsStore } from 'dashboard/stores/whatsappCalls';
const { isImpersonating } = useImpersonation();
@@ -34,6 +35,9 @@ class ActionCableConnector extends BaseActionCableConnector {
'conversation.updated': this.onConversationUpdated,
'account.cache_invalidated': this.onCacheInvalidate,
'copilot.message.created': this.onCopilotMessageCreated,
'whatsapp_call.incoming': this.onWhatsappCallIncoming,
'whatsapp_call.accepted': this.onWhatsappCallAccepted,
'whatsapp_call.ended': this.onWhatsappCallEnded,
};
}
@@ -200,6 +204,37 @@ class ActionCableConnector extends BaseActionCableConnector {
this.app.$store.dispatch('inboxes/revalidate', { newKey: keys.inbox });
this.app.$store.dispatch('teams/revalidate', { newKey: keys.team });
};
// eslint-disable-next-line class-methods-use-this
onWhatsappCallIncoming = data => {
const whatsappCallsStore = useWhatsappCallsStore();
whatsappCallsStore.addIncomingCall({
id: data.id,
callId: data.call_id,
direction: data.direction,
inboxId: data.inbox_id,
conversationId: data.conversation_id,
caller: data.caller,
sdpOffer: data.sdp_offer,
iceServers: data.ice_servers,
});
};
// eslint-disable-next-line class-methods-use-this
onWhatsappCallAccepted = data => {
const whatsappCallsStore = useWhatsappCallsStore();
const currentUserId = this.app.$store.getters.getCurrentUserID;
// If accepted by a different agent, remove from incoming list for this agent
if (data.accepted_by_agent_id !== currentUserId) {
whatsappCallsStore.handleCallAcceptedByOther(data.call_id);
}
};
// eslint-disable-next-line class-methods-use-this
onWhatsappCallEnded = data => {
const whatsappCallsStore = useWhatsappCallsStore();
whatsappCallsStore.handleCallEnded(data.call_id);
};
}
export default {