Skip to content

Commit d9d7e89

Browse files
committed
Merge
2 parents 5303a16 + 92634e8 commit d9d7e89

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

ui/component/header/view.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ const Header = (props: Props) => {
105105

106106
const urlParams = new URLSearchParams(search);
107107
const returnPath = urlParams.get('redirect');
108+
const isYoutubeAuthErrorPage =
109+
iYTSyncPage && (urlParams.get('error') === 'true' || Boolean(urlParams.get('error_message')));
108110

109111
// For pages that allow for "backing out", shows a backout option instead of the Home logo
110112
const canBackout = Boolean(backout);
@@ -314,6 +316,11 @@ const Header = (props: Props) => {
314316
// className="button--header-close"
315317
icon={ICONS.REMOVE}
316318
onClick={() => {
319+
if (isYoutubeAuthErrorPage) {
320+
push(`/$/${PAGES.YOUTUBE_SYNC}?reset_scroll=youtube`);
321+
return;
322+
}
323+
317324
if (!iYTSyncPage && !isPwdResetPage) {
318325
clearEmailEntry();
319326
clearPasswordEntry();

ui/page/youtubeSync/view.jsx

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const YoutubeTransferStatus = lazyImport(() =>
2121
);
2222

2323
const STATUS_TOKEN_PARAM = 'status_token';
24+
const ERROR_PARAM = 'error';
2425
const ERROR_MESSAGE_PARAM = 'error_message';
2526
const 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>

ui/scss/component/_main.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,15 @@ body {
941941
.checkbox {
942942
margin-bottom: var(--spacing-m);
943943
}
944+
945+
.card--youtube-sync {
946+
.nag--error.nag--relative {
947+
left: 0;
948+
right: 0;
949+
bottom: auto;
950+
margin-top: var(--spacing-s);
951+
}
952+
}
944953
}
945954

946955
// Temp hacks until 'section__actions--no-margin' is generic again.

0 commit comments

Comments
 (0)