@@ -21,6 +21,7 @@ const YoutubeTransferStatus = lazyImport(() =>
2121) ;
2222
2323const STATUS_TOKEN_PARAM = 'status_token' ;
24+ const ERROR_PARAM = 'error' ;
2425const ERROR_MESSAGE_PARAM = 'error_message' ;
2526const NEW_CHANNEL_PARAM = 'new_channel' ;
2627
@@ -40,14 +41,21 @@ export default function YoutubeSync(props: Props) {
4041 } = useHistory ( ) ;
4142 const urlParams = new URLSearchParams ( search ) ;
4243 const statusToken = urlParams . get ( STATUS_TOKEN_PARAM ) ;
44+ const hasErrorParam = urlParams . get ( ERROR_PARAM ) === 'true' ;
4345 const errorMessage = urlParams . get ( ERROR_MESSAGE_PARAM ) ;
4446 const newChannelParam = urlParams . get ( NEW_CHANNEL_PARAM ) ;
4547 const [ channel , setChannel ] = React . useState ( '' ) ;
4648 const [ language , setLanguage ] = React . useState ( getDefaultLanguage ( ) ) ;
4749 const [ nameError , setNameError ] = React . useState ( undefined ) ;
4850 const [ acknowledgedTerms , setAcknowledgedTerms ] = React . useState ( false ) ;
49- const [ addingNewChannel , setAddingNewChannel ] = React . useState ( newChannelParam ) ;
51+ const [ addingNewChannel , setAddingNewChannel ] = React . useState ( Boolean ( newChannelParam ) ) ;
52+ const hasYoutubeAuthError = hasErrorParam || Boolean ( errorMessage ) ;
53+ const youtubeAuthErrorMessage =
54+ hasYoutubeAuthError && ! errorMessage
55+ ? __ ( 'There was a problem connecting this YouTube channel. Please try again.' )
56+ : errorMessage ;
5057 const hasYoutubeChannels = youtubeChannels && youtubeChannels . length > 0 ;
58+ const showYoutubeTransferStatus = hasYoutubeChannels && ! addingNewChannel && ! hasYoutubeAuthError ;
5159
5260 React . useEffect ( ( ) => {
5361 const urlParamsInEffect = new URLSearchParams ( search ) ;
@@ -66,9 +74,7 @@ export default function YoutubeSync(props: Props) {
6674 } , [ statusToken , hasYoutubeChannels , doUserFetch ] ) ;
6775
6876 React . useEffect ( ( ) => {
69- if ( ! newChannelParam ) {
70- setAddingNewChannel ( false ) ;
71- }
77+ setAddingNewChannel ( Boolean ( newChannelParam ) ) ;
7278 } , [ newChannelParam ] ) ;
7379
7480 function handleCreateChannel ( ) {
@@ -95,7 +101,7 @@ export default function YoutubeSync(props: Props) {
95101 }
96102
97103 function handleNewChannel ( ) {
98- urlParams . append ( 'new_channel' , 'true' ) ;
104+ urlParams . set ( 'new_channel' , 'true' ) ;
99105 push ( `${ pathname } ?${ urlParams . toString ( ) } ` ) ;
100106 setAddingNewChannel ( true ) ;
101107 }
@@ -113,12 +119,13 @@ export default function YoutubeSync(props: Props) {
113119 return (
114120 < Wrapper >
115121 < div className = "main__channel-creation" >
116- { hasYoutubeChannels && ! addingNewChannel ? (
122+ { showYoutubeTransferStatus ? (
117123 < React . Suspense fallback = { null } >
118124 < YoutubeTransferStatus alwaysShow addNewChannel = { handleNewChannel } />
119125 </ React . Suspense >
120126 ) : (
121127 < Card
128+ className = "card--youtube-sync"
122129 title = { __ ( 'Sync your YouTube channel to %site_name%' , { site_name : IS_WEB ? SITE_NAME : 'Odysee' } ) }
123130 subtitle = { __ (
124131 `Don't want to manually upload? Get your YouTube videos in front of the %site_name% audience.` ,
@@ -197,11 +204,17 @@ export default function YoutubeSync(props: Props) {
197204 label = { __ ( 'Claim Now' ) }
198205 />
199206
200- { inSignUpFlow && ! errorMessage && (
207+ { inSignUpFlow && ! hasYoutubeAuthError && (
201208 < Button button = "link" label = { __ ( 'Skip' ) } onClick = { ( ) => doToggleInterestedInYoutubeSync ( ) } />
202209 ) }
203210
204- { errorMessage && < Button button = "link" label = { __ ( 'Skip' ) } navigate = { `/$/${ PAGES . REWARDS } ` } /> }
211+ { hasYoutubeAuthError && (
212+ < Button
213+ button = "link"
214+ label = { __ ( 'Skip' ) }
215+ navigate = { `/$/${ PAGES . YOUTUBE_SYNC } ?reset_scroll=youtube` }
216+ />
217+ ) }
205218 </ div >
206219 < div className = "help--card-actions" >
207220 < I18nMessage
@@ -229,7 +242,7 @@ export default function YoutubeSync(props: Props) {
229242 </ div >
230243 </ Form >
231244 }
232- nag = { errorMessage && < Nag message = { errorMessage } type = "error" relative /> }
245+ nag = { youtubeAuthErrorMessage && < Nag message = { youtubeAuthErrorMessage } type = "error" relative /> }
233246 />
234247 ) }
235248 </ div >
0 commit comments