You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The store's task-utils.ts contains ~15 utility functions that inspect raw task data to derive state flags (consult status, hold status, conference state, participant info). Many of these become redundant when task.uiControls is the source of truth. This document maps which utils to keep, simplify, or remove.
task.uiControls encodes all consult control states
getIsConferenceInProgress(task)
Used only for control visibility computation
task.uiControls.exitConference.isVisible
getConferenceParticipantsCount(task)
Used only for control visibility computation
SDK computes max participant check internally
getIsCustomerInCall(task)
Used only for control visibility computation
SDK computes internally
getIsConsultInProgress(task)
Used only for control visibility computation
SDK computes internally
findHoldStatus(task, mType, agentId)
Used for control visibility
SDK tracks hold state in context
Keep (Widget-layer concerns)
Function
Reason
isIncomingTask(task, agentId)
Store needs this for routing incoming tasks
getTaskStatus(task, agentId)
TaskList display needs human-readable status
getConferenceParticipants(task, agentId)
CallControl UI shows participant list (display, not control visibility)
isInteractionOnHold(task)
Timer logic needs this
findMediaResourceId(task, mType)
Switch-call actions need media resource IDs
findHoldTimestamp(task, mType)
Hold timer needs timestamp
Review (may simplify)
Function
Consideration
isSecondaryAgent(task)
May be replaceable by SDK context
isSecondaryEpDnAgent(task)
May be replaceable by SDK context
getConsultMPCState(task, agentId)
Review if still needed with SDK handling consult state
setmTypeForEPDN(task, mType)
Review if SDK simplifies this
Old → New Mapping
Old Function
Status
New Equivalent
getConsultStatus()
REMOVE
task.uiControls.endConsult, task.uiControls.switchToMainCall etc.
getIsConferenceInProgress()
REMOVE
task.uiControls.exitConference.isVisible
getConferenceParticipantsCount()
REMOVE
SDK internal check
getIsCustomerInCall()
REMOVE
SDK internal check
getIsConsultInProgress()
REMOVE
SDK internal check
findHoldStatus()
REMOVE
SDK tracks in TaskContext
isIncomingTask()
KEEP
—
getTaskStatus()
KEEP
Could enhance with SDK TaskState
getConferenceParticipants()
KEEP
Display only
isInteractionOnHold()
KEEP
Timer display
findMediaResourceId()
KEEP
Action parameter
findHoldTimestamp()
KEEP
Timer display
Before/After: Removing getConsultStatus Usage
Before (consumed in task-util.ts::getControlsVisibility)
// task-util.ts — old approachimport{getConsultStatus,ConsultStatus,getIsConsultInProgress,getIsCustomerInCall,getConferenceParticipantsCount,findHoldStatus}from'@webex/cc-store';exportfunctiongetControlsVisibility(deviceType,featureFlags,task,agentId,conferenceEnabled){// Derive consult status by inspecting raw task dataconsttaskConsultStatus=getConsultStatus(task,agentId);constisConsultInitiated=taskConsultStatus===ConsultStatus.CONSULT_INITIATED;constisConsultAccepted=taskConsultStatus===ConsultStatus.CONSULT_ACCEPTED;constisBeingConsulted=taskConsultStatus===ConsultStatus.BEING_CONSULTED_ACCEPTED;constisConsultCompleted=taskConsultStatus===ConsultStatus.CONSULT_COMPLETED;// Derive hold status from raw task mediaconstisHeld=findHoldStatus(task,'mainCall',agentId);constconsultCallHeld=findHoldStatus(task,'consult',agentId);// Derive conference state from raw task dataconstisConferenceInProgress=task?.data?.isConferenceInProgress??false;constisConsultInProgress=getIsConsultInProgress(task);constisCustomerInCall=getIsCustomerInCall(task);constconferenceParticipantsCount=getConferenceParticipantsCount(task);// 20+ individual visibility functions using these derived states...return{/* 22 controls + 7 state flags */};}
After (all above replaced by task.uiControls)
// task-util.ts — DELETED or reduced to:export{findHoldTimestamp}from'./task-util';// Only keep for timer display// In useCallControl hook — no imports from store task-utils for controls:constcontrols=currentTask?.uiControls??getDefaultUIControls();// All 17 controls come pre-computed from SDK. Zero store util calls needed.
Before/After: findHoldStatus Removal
Before (used in controls computation)
// store/task-utils.tsexportfunctionfindHoldStatus(task: ITask,mType: string,agentId: string): boolean{if(!task?.data?.interaction?.media)returnfalse;constmedia=Object.values(task.data.interaction.media).find(m=>m.mType===mType);if(!media?.participants)returnfalse;constparticipant=task.data.interaction.participants[agentId];returnparticipant?.isHold??false;}// task-util.ts — consumed for control visibilityconstisHeld=findHoldStatus(task,'mainCall',agentId);constconsultCallHeld=findHoldStatus(task,'consult',agentId);
After
// REMOVED from store/task-utils.ts — SDK tracks hold state in TaskContext:// - task.uiControls.hold.isEnabled indicates holdable// - task.uiControls.switchToConsult.isVisible indicates consult call is held// No widget-side derivation needed.
// store/task-utils.ts — can now derive status from uiControlsexportfunctiongetTaskStatus(task: ITask,agentId: string): string{constcontrols=task.uiControls;if(!controls)return'Unknown';if(controls.wrapup.isVisible)return'Wrap Up';if(controls.endConsult.isVisible)return'Consulting';if(controls.exitConference.isVisible)return'Conference';// NOTE: Do NOT derive held state from controls.hold.isEnabled — hold can be// disabled in consult/transition states even when call is not held.// Use task data instead (agentId needed for participant lookup):if(findHoldStatus(task,'mainCall',agentId))return'Held';if(controls.end.isVisible)return'Connected';if(controls.accept.isVisible)return'Offered';return'Unknown';}