Created
September 2, 2021 15:17
-
-
Save warodri-sendbird/fcc8910371ee8a1a6b566e1b5caa8be9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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