cleanup - broken?

This commit is contained in:
Sean Yesmunt 2020-07-07 18:24:24 -04:00
parent f9325a816e
commit d6335464d3
4 changed files with 44 additions and 26 deletions

View file

@ -136,7 +136,7 @@
"imagesloaded": "^4.1.4",
"json-loader": "^0.5.4",
"lbry-format": "https://github.com/lbryio/lbry-format.git",
"lbry-redux": "lbryio/lbry-redux#67d8540ccc0fbedf018ae0bdfe3cae17660a5a6c",
"lbry-redux": "lbryio/lbry-redux#1523bbd33fa215bedebc15bbf2b71a3f7c837a5b",
"lbryinc": "lbryio/lbryinc#cff5dd60934c4c6080e135f47ebbece1548c658c",
"lint-staged": "^7.0.2",
"localforage": "^1.7.1",

View file

@ -7,7 +7,6 @@ import Button from 'component/button';
import { LbryFirst } from 'lbry-redux';
import LicenseType from './license-type';
import Card from 'component/common/card';
import { getAuthToken } from 'util/saved-passwords';
import ErrorText from 'component/common/error-text';
// @if TARGET='app'
import { ipcRenderer } from 'electron';
@ -39,18 +38,20 @@ function PublishAdditionalOptions(props: Props) {
updatePublishForm,
useLBRYUploader,
needsYTAuth,
accessToken,
fetchAccessToken,
} = props;
const [hideSection, setHideSection] = usePersistedState('publish-advanced-options', true);
const [hasLaunchedLbryFirst, setHasLaunchedLbryFirst] = React.useState(false);
const [ytError, setYtError] = React.useState(true);
const [ytError, setYtError] = React.useState(false);
const isLBRYFirstUser = user && user.lbry_first_approved;
const showLbryFirstCheckbox = !IS_WEB && isLBRYFirstUser && hasLaunchedLbryFirst;
const authToken = getAuthToken();
function toggleHideSection() {
setHideSection(!hideSection);
}
// @if TARGET='app'
function signup() {
updatePublishForm({ ytSignupPending: true });
LbryFirst.ytSignup()
@ -65,6 +66,8 @@ function PublishAdditionalOptions(props: Props) {
}
function unlink() {
setYtError(false);
LbryFirst.remove()
.then(response => {
updatePublishForm({ needsYTAuth: true });
@ -76,17 +79,23 @@ function PublishAdditionalOptions(props: Props) {
}
React.useEffect(() => {
if (isLBRYFirstUser) {
if (!accessToken) {
fetchAccessToken();
}
}, [accessToken, fetchAccessToken]);
React.useEffect(() => {
if (isLBRYFirstUser && !hasLaunchedLbryFirst) {
ipcRenderer.send('launch-lbry-first');
ipcRenderer.on('lbry-first-launched', () => {
setHasLaunchedLbryFirst(true);
});
}
}, [isLBRYFirstUser, setHasLaunchedLbryFirst]);
}, [isLBRYFirstUser, hasLaunchedLbryFirst, setHasLaunchedLbryFirst]);
React.useEffect(() => {
if (useLBRYUploader) {
LbryFirst.hasYTAuth(authToken)
if (useLBRYUploader && isLBRYFirstUser && hasLaunchedLbryFirst && accessToken) {
LbryFirst.hasYTAuth(accessToken)
.then(response => {
updatePublishForm({ needsYTAuth: !response.HasAuth });
})
@ -95,7 +104,8 @@ function PublishAdditionalOptions(props: Props) {
console.error(error); // eslint-disable-line
});
}
}, [authToken, updatePublishForm, useLBRYUploader]);
}, [updatePublishForm, useLBRYUploader, isLBRYFirstUser, hasLaunchedLbryFirst, accessToken]);
// @endif
return (
<Card
@ -103,8 +113,9 @@ function PublishAdditionalOptions(props: Props) {
<React.Fragment>
{!hideSection && (
<div className={classnames({ 'card--disabled': !name })}>
<div className="section">
{showLbryFirstCheckbox && (
{/* @if TARGET='app' */}
{showLbryFirstCheckbox && (
<div className="section">
<>
<FormField
checked={useLBRYUploader}
@ -134,8 +145,9 @@ function PublishAdditionalOptions(props: Props) {
</div>
)}
</>
)}
</div>
</div>
)}
{/* @endif */}
<div className="section">
<FormField
label={__('Language')}

View file

@ -213,8 +213,6 @@ function PublishForm(props: Props) {
</div>
)}
<section>
{!formDisabled && !formValid && <PublishFormErrors />}
<div className="card__actions">
<Button
button="primary"
@ -227,15 +225,23 @@ function PublishForm(props: Props) {
<Button button="link" onClick={clearPublish} label={__('Cancel')} />
</div>
<p className="help">
<I18nMessage
tokens={{
lbry_terms_of_service: (
<Button button="link" href="https://www.lbry.com/termsofservice" label={__('LBRY Terms of Service')} />
),
}}
>
By continuing, you accept the %lbry_terms_of_service%.
</I18nMessage>
{!formDisabled && !formValid ? (
<PublishFormErrors />
) : (
<I18nMessage
tokens={{
lbry_terms_of_service: (
<Button
button="link"
href="https://www.lbry.com/termsofservice"
label={__('LBRY Terms of Service')}
/>
),
}}
>
By continuing, you accept the %lbry_terms_of_service%.
</I18nMessage>
)}
</p>
</section>
</div>

View file

@ -6383,9 +6383,9 @@ lazy-val@^1.0.4:
yargs "^13.2.2"
zstd-codec "^0.1.1"
lbry-redux@lbryio/lbry-redux#67d8540ccc0fbedf018ae0bdfe3cae17660a5a6c:
lbry-redux@lbryio/lbry-redux#1523bbd33fa215bedebc15bbf2b71a3f7c837a5b:
version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/67d8540ccc0fbedf018ae0bdfe3cae17660a5a6c"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/1523bbd33fa215bedebc15bbf2b71a3f7c837a5b"
dependencies:
proxy-polyfill "0.1.6"
reselect "^3.0.0"