-
Notifications
You must be signed in to change notification settings - Fork 65
fix(cc-task): fix hold/resume not working after recording pause/resume #667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
c8c0a28
ae62a5c
28233f5
87e64aa
3bcf6af
8a0cc4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import store, { | |
| getConferenceParticipants, | ||
| Participant, | ||
| findMediaResourceId, | ||
| findHoldStatus, | ||
| MEDIA_TYPE_TELEPHONY_LOWER, | ||
| } from '@webex/cc-store'; | ||
| import {getControlsVisibility} from './Utils/task-util'; | ||
|
|
@@ -297,6 +298,7 @@ export const useCallControl = (props: useCallControlProps) => { | |
| agentId, | ||
| } = props; | ||
| const [isRecording, setIsRecording] = useState(true); | ||
| const [isHeld, setIsHeld] = useState(false); | ||
| const [buddyAgents, setBuddyAgents] = useState<BuddyDetails[]>([]); | ||
| const [loadingBuddyAgents, setLoadingBuddyAgents] = useState(false); | ||
| const [consultAgentName, setConsultAgentName] = useState<string>('Consult Agent'); | ||
|
|
@@ -445,6 +447,21 @@ export const useCallControl = (props: useCallControlProps) => { | |
| } | ||
| }, [currentTask, logger, lastTargetType, consultAgentName, setConsultAgentName]); | ||
|
|
||
| // Sync local hold state from task data only when a different task is selected | ||
| // (not on every currentTask reference change, which would overwrite event-driven state) | ||
| useEffect(() => { | ||
| if (currentTask?.data?.interaction) { | ||
| try { | ||
| setIsHeld(findHoldStatus(currentTask, 'mainCall', agentId)); | ||
| } catch (error) { | ||
| logger?.warn(`CC-Widgets: Task: Error syncing hold state - ${error?.message || error}`, { | ||
| module: 'useCallControl', | ||
| method: 'syncHoldState', | ||
| }); | ||
| } | ||
| } | ||
| }, [currentTask?.data?.interactionId, agentId]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new hold sync effect only depends on Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentionally keeping There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This effect only depends on Useful? React with 👍 / 👎. |
||
|
|
||
| // Extract main call timestamp whenever currentTask changes | ||
| useEffect(() => { | ||
| extractConsultingAgent(); | ||
|
|
@@ -530,6 +547,7 @@ export const useCallControl = (props: useCallControlProps) => { | |
|
|
||
| const holdCallback = () => { | ||
| try { | ||
| setIsHeld(true); | ||
| if (onHoldResume) { | ||
| onHoldResume({ | ||
| isHeld: true, | ||
|
|
@@ -546,6 +564,7 @@ export const useCallControl = (props: useCallControlProps) => { | |
|
|
||
| const resumeCallback = () => { | ||
| try { | ||
| setIsHeld(false); | ||
| if (onHoldResume) { | ||
| onHoldResume({ | ||
| isHeld: false, | ||
|
|
@@ -595,10 +614,12 @@ export const useCallControl = (props: useCallControlProps) => { | |
| const pauseRecordingCallback = () => { | ||
| try { | ||
| setIsRecording(false); | ||
| onRecordingToggle({ | ||
| isRecording: false, | ||
| task: currentTask, | ||
| }); | ||
| if (onRecordingToggle) { | ||
| onRecordingToggle({ | ||
| isRecording: false, | ||
| task: currentTask, | ||
| }); | ||
| } | ||
| } catch (error) { | ||
| logger?.error(`CC-Widgets: Task: Error in pauseRecordingCallback - ${error.message}`, { | ||
| module: 'useCallControl', | ||
|
|
@@ -610,10 +631,12 @@ export const useCallControl = (props: useCallControlProps) => { | |
| const resumeRecordingCallback = () => { | ||
| try { | ||
| setIsRecording(true); | ||
| onRecordingToggle({ | ||
| isRecording: true, | ||
| task: currentTask, | ||
| }); | ||
| if (onRecordingToggle) { | ||
| onRecordingToggle({ | ||
| isRecording: true, | ||
| task: currentTask, | ||
| }); | ||
| } | ||
| } catch (error) { | ||
| logger?.error(`CC-Widgets: Task: Error in resumeRecordingCallback - ${error.message}`, { | ||
| module: 'useCallControl', | ||
|
|
@@ -648,8 +671,8 @@ export const useCallControl = (props: useCallControlProps) => { | |
| store.removeTaskCallback(TASK_EVENTS.TASK_RESUME, resumeCallback, interactionId); | ||
| store.removeTaskCallback(TASK_EVENTS.TASK_END, endCallCallback, interactionId); | ||
| store.removeTaskCallback(TASK_EVENTS.AGENT_WRAPPEDUP, wrapupCallCallback, interactionId); | ||
| store.removeTaskCallback(TASK_EVENTS.CONTACT_RECORDING_PAUSED, pauseRecordingCallback, interactionId); | ||
| store.removeTaskCallback(TASK_EVENTS.CONTACT_RECORDING_RESUMED, resumeRecordingCallback, interactionId); | ||
| store.removeTaskCallback(TASK_EVENTS.TASK_RECORDING_PAUSED, pauseRecordingCallback, interactionId); | ||
| store.removeTaskCallback(TASK_EVENTS.TASK_RECORDING_RESUMED, resumeRecordingCallback, interactionId); | ||
| }; | ||
| }, [currentTask]); | ||
|
|
||
|
|
@@ -927,11 +950,14 @@ export const useCallControl = (props: useCallControlProps) => { | |
| currentTask.cancelAutoWrapupTimer(); | ||
| }; | ||
|
|
||
| const controlVisibility = useMemo( | ||
| const controlVisibilityBase = useMemo( | ||
| () => getControlsVisibility(deviceType, featureFlags, currentTask, agentId, conferenceEnabled, logger), | ||
| [deviceType, featureFlags, currentTask, agentId, conferenceEnabled, logger] | ||
| ); | ||
|
|
||
| // Override isHeld with event-driven local state to avoid stale task data from getAllTasks() | ||
| const controlVisibility = useMemo(() => ({...controlVisibilityBase, isHeld}), [controlVisibilityBase, isHeld]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Overriding only Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Overriding only Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Useful? React with 👍 / 👎. |
||
|
|
||
| // Add useEffect for auto wrap-up timer | ||
| useEffect(() => { | ||
| let timerId: NodeJS.Timeout; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont we have this already in getControlsVisibility ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — removed the separate
findHoldStatusimport. The sync useEffect now reads fromcontrolVisibilityBase.isHeld(which already computes this viagetControlsVisibility), eliminating the duplication. See 3bcf6af.