rn: adapt to API changes in google signin

This commit is contained in:
Saúl Ibarra Corretgé 2019-06-18 13:16:49 +02:00 committed by Saúl Ibarra Corretgé
parent 4591b36c3e
commit 54a9b9199e
2 changed files with 24 additions and 6 deletions

View File

@ -35,6 +35,15 @@ class GoogleApi {
}
}
/**
* Retrieves the current tokens.
*
* @returns {Promise}
*/
getTokens(): Promise<*> {
return GoogleSignin.getTokens();
}
/**
* Retrieves the available YouTube streams the user can use for live
* streaming.

View File

@ -119,13 +119,22 @@ class StartLiveStreamDialog extends AbstractStartLiveStreamDialog<Props> {
* @returns {void}
*/
_onUserChanged(response) {
if (response && response.accessToken) {
googleApi.getYouTubeLiveStreams(response.accessToken)
.then(broadcasts => {
this.setState({
broadcasts
if (response) {
googleApi.getTokens()
.then(tokens => {
googleApi.getYouTubeLiveStreams(tokens.accessToken)
.then(broadcasts => {
this.setState({
broadcasts
});
});
})
.catch(() => {
this.setState({
broadcasts: undefined,
streamKey: undefined
});
});
});
} else {
this.setState({
broadcasts: undefined,