Skip to content
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

onMuteToggle fails on page refresh #953

Open
joingram-priceline opened this issue Dec 18, 2024 · 4 comments
Open

onMuteToggle fails on page refresh #953

joingram-priceline opened this issue Dec 18, 2024 · 4 comments

Comments

@joingram-priceline
Copy link

joingram-priceline commented Dec 18, 2024

We are using the following code and onMuteToggle fails when the page is refreshed. onEnqueuedNextState works fine after a page refresh. We can see in the console log that mute events are still being received from amazon connect after the page refresh but code in onMuteToggle is not triggering.

if (connect) { try { connect.agent((agent) => { agent.onStateChange(() => { ... }) agent.onMuteToggle((agentMutedStatus) => {...}) agent.onEnqueuedNextState(() => {...}) }) } catch (err) {} }

@andywang219
Copy link
Contributor

Hi,

Could you provide more details on the steps you did to reproduce the issue? Also, which Streams version are you using for testing and could you share where you've placed your logic to subscribe to onMuteToggle()?

I did a quick test with the following code:

if (connect) {
   connect.agent((agent) => {
        agent.onMuteToggle((data) => {
               console.log('muteToggle triggered');
         });
    });
}

and everything was working as expected. The console.log() inside of onMuteToggle() was being triggered even after refreshing the page.

@joingram-priceline
Copy link
Author

joingram-priceline commented Jan 3, 2025

Hi,

Sure, here are the steps:

  1. Make an outbound or inbound call from the app
  2. Connect to the call
  3. Use mute toggle from app
  4. Observe console.log inside of agent.onMuteToggle() works normally
  5. Refresh the page
  6. Use mute toggle from app
  7. Observe console.log inside of agent.onMuteToggle() no longer triggers, but the event is still shown in the console: [AgentMuteToggle] Received MUTE event, nextMuteState: true

We are using amazon-connect-streams version 2.18.0

As for code, we have the same as your example. I will share a bit more context for it though.

const MyComponent = (): React.ReactElement => {
  	const initializeCallPanel = useCallback(async () => {
	    await initCcpInstance()

	    connect?.core.onInitialized(() => {
	      console.log('Connect Initialized')
	      setIsInitialized(true)
	      startAgentListeners()
	    })
	  }, [setIsInitialized])

	  useEffect(() => {
	    if (user && !isInitialized) {
	      initializeCallPanel()
	    }
	  }, [user, isInitialized, initializeCallPanel])

	  [...]

	  return Component
}

export const startAgentListeners = (): void => {
  if (connect) {
    try {
      connect.agent((agent) => {
        agent.onStateChange(() => {...})

        agent.onMuteToggle((agentMutedStatus) => {
          console.log('foobar', agentMutedStatus)
        })

        agent.onEnqueuedNextState(() => {...})
      })
    } catch (err) {...}
  }
}

@andywang219
Copy link
Contributor

I see. One thing to note is that if you refresh the page while on a call, that call will be broken.

If you refresh prior to being on a call, does the onMuteToggle() work? <- This was the scenario that I tested.

@joingram-priceline
Copy link
Author

joingram-priceline commented Jan 3, 2025

Yes onMuteToggle() works prior to the call. Is there a way onMuteToggle() work for my scenario of being on a call when the page is refreshed? The built-in Amazon Connect CCP app has this scenario covered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants