diff --git a/package.json b/package.json index 33fc33ada..9c53dd06d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/ui/component/publishAdditionalOptions/view.jsx b/ui/component/publishAdditionalOptions/view.jsx index bb80fccb9..4cc614249 100644 --- a/ui/component/publishAdditionalOptions/view.jsx +++ b/ui/component/publishAdditionalOptions/view.jsx @@ -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 ( {!hideSection && (
-
- {showLbryFirstCheckbox && ( + {/* @if TARGET='app' */} + {showLbryFirstCheckbox && ( +
<> )} - )} -
+
+ )} + {/* @endif */}
)}
- {!formDisabled && !formValid && } -

- - ), - }} - > - By continuing, you accept the %lbry_terms_of_service%. - + {!formDisabled && !formValid ? ( + + ) : ( + + ), + }} + > + By continuing, you accept the %lbry_terms_of_service%. + + )}

diff --git a/yarn.lock b/yarn.lock index 0924662c4..7d3a351c7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"