Skip to content

Instantly share code, notes, and snippets.

@warodri-sendbird
Created September 2, 2021 15:17
Show Gist options
  • Save warodri-sendbird/fcc8910371ee8a1a6b566e1b5caa8be9 to your computer and use it in GitHub Desktop.
Save warodri-sendbird/fcc8910371ee8a1a6b566e1b5caa8be9 to your computer and use it in GitHub Desktop.
const connect = () => {
if (!state.connecting) {
if (state.userId && state.nickname) {
dispatch({ type: 'start-connection' });
Keyboard.dismiss();
sendbird.connect(state.userId, (err, user) => {
if (!err) {
if (user.nickname !== state.nickname) {
sendbird.updateCurrentUserInfo(state.nickname, '', (err, user) => {
dispatch({ type: 'end-connection' });
if (!err) {
start(user);
} else {
showError(err.message);
}
});
} else {
dispatch({ type: 'end-connection' });
start(user);
}
} else {
dispatch({ type: 'end-connection' });
showError(err.message);
}
});
} else {
showError('Please put your user ID and nickname.');
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment