Skip to content

Commit

Permalink
Fixed missing operator update status (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyco97 authored Sep 24, 2024
1 parent ff5da19 commit b534b40
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 127 deletions.
21 changes: 20 additions & 1 deletion components/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const Layout: FC<LayoutProps> = ({ children }) => {
const currentUsername = authStore.username
const { operators } = useSelector((state: RootState) => state.operators)
const { profile } = useSelector((state: RootState) => state.user)
const {avoidClose} = useSelector((state: RootState) => state.sideDrawer)
const { avoidClose } = useSelector((state: RootState) => state.sideDrawer)

const productName = getProductName()
// Get current page name, clean the path from / and capitalize page name
Expand Down Expand Up @@ -470,6 +470,25 @@ export const Layout: FC<LayoutProps> = ({ children }) => {
userInformation?.default_device?.type,
])

useEventListener('phone-island-extensions-update', (data) => {
const opName: any = Object.keys(data)[0]

let extensionInformation: any = {
conversations: data[opName]?.conversations,
dnd: data[opName]?.dnd,
ip: data[opName]?.ip,
number: data[opName]?.number,
port: data[opName]?.port,
sipuseragent: data[opName]?.sipuseragent,
status: data[opName]?.status,
username: data[opName]?.username,
exten: data[opName]?.exten,
name: data[opName]?.name,
}

store.dispatch.operators.updateExten(data[opName]?.number, extensionInformation)
})

useEventListener('phone-island-conversations', (data) => {
const opName = Object.keys(data)[0]
const conversations = data[opName].conversations
Expand Down
4 changes: 2 additions & 2 deletions components/queueManager/Realtime/RealTimeManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ export const RealTimeManagement: FC<RealTimeManagementProps> = ({ className }):
const conversation = conversations[c]
//check if exists and is inside queue
if (
conversation.connected === true &&
conversation.throughQueue === true &&
conversation?.connected === true &&
conversation?.throughQueue === true &&
queueManagerStore?.queues[conversation.queueId] !== undefined
) {
const queueId = conversation.queueId
Expand Down
8 changes: 4 additions & 4 deletions models/queueManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ export const queueManagerQueues = createModel<RootModel>()({

let connectedCalls: any[] = []
Object.values(operators).forEach((operator: any) => {
operator.conversations?.forEach((conversation: any) => {
operator?.conversations?.forEach((conversation: any) => {
if (
conversation.throughQueue &&
conversation.connected &&
conversation.queueId === queueId
conversation?.throughQueue &&
conversation?.connected &&
conversation?.queueId === queueId
) {
connectedCalls.push({ conversation, operatorUsername: operator?.username })
}
Expand Down
6 changes: 3 additions & 3 deletions models/queues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ export const queues = createModel<RootModel>()({
Object.values(operators).forEach((operator: any) => {
operator.conversations?.forEach((conversation: any) => {
if (
conversation.throughQueue &&
conversation.connected &&
conversation.queueId === queueId
conversation?.throughQueue &&
conversation?.connected &&
conversation?.queueId === queueId
) {
connectedCalls.push({ conversation, operatorUsername: operator?.username })
}
Expand Down
Loading

0 comments on commit b534b40

Please sign in to comment.