[Problem/Question]
// Detailed description of issue.
I’m using an inside an (ReactJS) to display a conversation and this all works correctly.
I’m disconnecting when the browser tab becomes hidden and reconnect when it comes back into focus - this is done to save on open concurrent connections.
Disconnecting and Reconnecting work fine, I see the messages flow in after reconnection and I see the “trying to connect” ui under the textinput. However, after reconnection the textfield remains “disabled” an I can not send additional message.
// If problem, please fill out the below. If question, please delete.
[UIKit Version]
// What version of the SDK are you using?
“react”: “^17.0.1”
“@sendbird/uikit-react”: “^3.6.0”
[Reproduction Steps]
// Please provide reproduction steps and, if possible, code snippets.
add this to your conversation component:
const globalStore = useSendbirdStateContext();
const getGroupChannel = sendbirdSelectors.getGetGroupChannel(globalStore);
const disconnect = sendbirdSelectors.getDisconnect(globalStore);
const connect = sendbirdSelectors.getConnect(globalStore);
//...
useLayoutEffect(() => {
async function handleVisibilityChange() {
try {
if (document.visibilityState === 'hidden') {
console.log('disconnect');
disconnect()
.then((res) => console.log(res))
.catch((err) => console.log(err));
}
if (document.visibilityState === 'visible') {
console.log('--Connection changed from hidden to visible');
connect(token.userId, token.accessToken)
.then( async (res) => {
console.log(res) // <--- this works, reconnection is successful
})
.catch((err) => console.log('err',err));
}
} catch (err) {
}
}
document.addEventListener('visibilitychange', handleVisibilityChange);
return () => {
document.removeEventListener('visibilitychange', handleVisibilityChange);
};
}, [globalStore]);
[Frequency]
// How frequently is this issue occurring?
always
[Current impact]
// How is this currently impacting your implementation?
I can’t send messages.