only start lbryFirst daemon for approved users
This commit is contained in:
parent
4291c36c58
commit
f9325a816e
5 changed files with 137 additions and 95 deletions
|
@ -4,7 +4,7 @@
|
||||||
import '@babel/polyfill';
|
import '@babel/polyfill';
|
||||||
import SemVer from 'semver';
|
import SemVer from 'semver';
|
||||||
import https from 'https';
|
import https from 'https';
|
||||||
import { app, dialog, ipcMain, session, shell } from 'electron';
|
import { app, dialog, ipcMain, session, shell, ipcRenderer } from 'electron';
|
||||||
import { autoUpdater } from 'electron-updater';
|
import { autoUpdater } from 'electron-updater';
|
||||||
import { Lbry, LbryFirst } from 'lbry-redux';
|
import { Lbry, LbryFirst } from 'lbry-redux';
|
||||||
import LbryFirstInstance from './LbryFirstInstance';
|
import LbryFirstInstance from './LbryFirstInstance';
|
||||||
|
@ -95,6 +95,8 @@ const startLbryFirst = async () => {
|
||||||
try {
|
try {
|
||||||
await LbryFirst.status();
|
await LbryFirst.status();
|
||||||
isLbryFirstRunning = true;
|
isLbryFirstRunning = true;
|
||||||
|
console.log('LbryFirst: Already running');
|
||||||
|
handleLbryFirstLaunched();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('status fails', e);
|
console.log('status fails', e);
|
||||||
console.log('Starting LbryFirst');
|
console.log('Starting LbryFirst');
|
||||||
|
@ -118,12 +120,17 @@ const startLbryFirst = async () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await lbryFirst.launch();
|
await lbryFirst.launch();
|
||||||
|
handleLbryFirstLaunched();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('e', e);
|
console.log('e', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleLbryFirstLaunched = () => {
|
||||||
|
rendererWindow.webContents.send('lbry-first-launched');
|
||||||
|
};
|
||||||
|
|
||||||
// When we are starting the app, ensure there are no other apps already running
|
// When we are starting the app, ensure there are no other apps already running
|
||||||
const gotSingleInstanceLock = app.requestSingleInstanceLock();
|
const gotSingleInstanceLock = app.requestSingleInstanceLock();
|
||||||
|
|
||||||
|
@ -160,7 +167,6 @@ if (!gotSingleInstanceLock) {
|
||||||
|
|
||||||
app.on('ready', async () => {
|
app.on('ready', async () => {
|
||||||
await startDaemon();
|
await startDaemon();
|
||||||
await startLbryFirst();
|
|
||||||
startSandbox();
|
startSandbox();
|
||||||
|
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
|
@ -370,6 +376,15 @@ ipcMain.on('version-info-requested', () => {
|
||||||
requestLatestRelease();
|
requestLatestRelease();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.on('launch-lbry-first', async () => {
|
||||||
|
try {
|
||||||
|
await startLbryFirst();
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Failed to start LbryFirst');
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
process.on('uncaughtException', error => {
|
process.on('uncaughtException', error => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
dialog.showErrorBox('Error Encountered', `Caught error: ${error}`);
|
dialog.showErrorBox('Error Encountered', `Caught error: ${error}`);
|
||||||
|
|
|
@ -137,7 +137,7 @@
|
||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
||||||
"lbry-redux": "lbryio/lbry-redux#67d8540ccc0fbedf018ae0bdfe3cae17660a5a6c",
|
"lbry-redux": "lbryio/lbry-redux#67d8540ccc0fbedf018ae0bdfe3cae17660a5a6c",
|
||||||
"lbryinc": "lbryio/lbryinc#0f6fd2c33812fb1c1e393dd35b1a7560d3ba3fe2",
|
"lbryinc": "lbryio/lbryinc#cff5dd60934c4c6080e135f47ebbece1548c658c",
|
||||||
"lint-staged": "^7.0.2",
|
"lint-staged": "^7.0.2",
|
||||||
"localforage": "^1.7.1",
|
"localforage": "^1.7.1",
|
||||||
"lodash-es": "^4.17.14",
|
"lodash-es": "^4.17.14",
|
||||||
|
|
|
@ -1261,5 +1261,9 @@
|
||||||
"Delete Your Channel": "Delete Your Channel",
|
"Delete Your Channel": "Delete Your Channel",
|
||||||
"Remove from Blocked List": "Remove from Blocked List",
|
"Remove from Blocked List": "Remove from Blocked List",
|
||||||
"Are you sure you want to remove this from the list?": "Are you sure you want to remove this from the list?",
|
"Are you sure you want to remove this from the list?": "Are you sure you want to remove this from the list?",
|
||||||
"Automagically upload to your youtube channel!": "Automagically upload to your youtube channel!"
|
"CableTube Escape Artists": "CableTube Escape Artists",
|
||||||
|
"Unlink YouTube Channel": "Unlink YouTube Channel",
|
||||||
|
"Sign In With YouTube": "Sign In With YouTube",
|
||||||
|
"There was an error with LBRY first publishing.": "There was an error with LBRY first publishing.",
|
||||||
|
"Automagically upload to your youtube channel.": "Automagically upload to your youtube channel."
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,13 @@ import usePersistedState from 'effects/use-persisted-state';
|
||||||
import { FormField } from 'component/common/form';
|
import { FormField } from 'component/common/form';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import { LbryFirst } from 'lbry-redux';
|
import { LbryFirst } from 'lbry-redux';
|
||||||
|
|
||||||
import LicenseType from './license-type';
|
import LicenseType from './license-type';
|
||||||
import Card from 'component/common/card';
|
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';
|
||||||
|
// @endif
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
user: ?User,
|
user: ?User,
|
||||||
|
@ -35,56 +39,63 @@ function PublishAdditionalOptions(props: Props) {
|
||||||
updatePublishForm,
|
updatePublishForm,
|
||||||
useLBRYUploader,
|
useLBRYUploader,
|
||||||
needsYTAuth,
|
needsYTAuth,
|
||||||
fetchAccessToken,
|
|
||||||
accessToken,
|
|
||||||
} = props;
|
} = props;
|
||||||
const [hideSection, setHideSection] = usePersistedState('publish-advanced-options', true);
|
const [hideSection, setHideSection] = usePersistedState('publish-advanced-options', true);
|
||||||
|
const [hasLaunchedLbryFirst, setHasLaunchedLbryFirst] = React.useState(false);
|
||||||
|
const [ytError, setYtError] = React.useState(true);
|
||||||
const isLBRYFirstUser = user && user.lbry_first_approved;
|
const isLBRYFirstUser = user && user.lbry_first_approved;
|
||||||
|
const showLbryFirstCheckbox = !IS_WEB && isLBRYFirstUser && hasLaunchedLbryFirst;
|
||||||
|
const authToken = getAuthToken();
|
||||||
|
|
||||||
function toggleHideSection() {
|
function toggleHideSection() {
|
||||||
setHideSection(!hideSection);
|
setHideSection(!hideSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
function signup() {
|
function signup() {
|
||||||
updatePublishForm({ ytSignupPending: true });
|
updatePublishForm({ ytSignupPending: true });
|
||||||
LbryFirst.ytSignup()
|
LbryFirst.ytSignup()
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log(response);
|
|
||||||
updatePublishForm({ needsYTAuth: false, ytSignupPending: false });
|
updatePublishForm({ needsYTAuth: false, ytSignupPending: false });
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
updatePublishForm({ ytSignupPending: false });
|
updatePublishForm({ ytSignupPending: false });
|
||||||
console.log(error);
|
setYtError(true);
|
||||||
|
console.error(error); // eslint-disable-line
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function unlink() {
|
function unlink() {
|
||||||
LbryFirst.remove()
|
LbryFirst.remove()
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log(response);
|
|
||||||
updatePublishForm({ needsYTAuth: true });
|
updatePublishForm({ needsYTAuth: true });
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log(error);
|
setYtError(true);
|
||||||
|
console.error(error); // eslint-disable-line
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!accessToken) {
|
if (isLBRYFirstUser) {
|
||||||
fetchAccessToken();
|
ipcRenderer.send('launch-lbry-first');
|
||||||
|
ipcRenderer.on('lbry-first-launched', () => {
|
||||||
|
setHasLaunchedLbryFirst(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [accessToken, fetchAccessToken]);
|
}, [isLBRYFirstUser, setHasLaunchedLbryFirst]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (useLBRYUploader) {
|
if (useLBRYUploader) {
|
||||||
LbryFirst.hasYTAuth(accessToken)
|
LbryFirst.hasYTAuth(authToken)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log(response);
|
|
||||||
updatePublishForm({ needsYTAuth: !response.HasAuth });
|
updatePublishForm({ needsYTAuth: !response.HasAuth });
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log(error);
|
setYtError(true);
|
||||||
|
console.error(error); // eslint-disable-line
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [accessToken, updatePublishForm, useLBRYUploader]);
|
}, [authToken, updatePublishForm, useLBRYUploader]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
|
@ -92,29 +103,40 @@ function PublishAdditionalOptions(props: Props) {
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{!hideSection && (
|
{!hideSection && (
|
||||||
<div className={classnames({ 'card--disabled': !name })}>
|
<div className={classnames({ 'card--disabled': !name })}>
|
||||||
{!IS_WEB && isLBRYFirstUser && (
|
<div className="section">
|
||||||
|
{showLbryFirstCheckbox && (
|
||||||
|
<>
|
||||||
<FormField
|
<FormField
|
||||||
|
checked={useLBRYUploader}
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
name="use_lbry_uploader_checkbox"
|
name="use_lbry_uploader_checkbox"
|
||||||
onChange={event => updatePublishForm({ useLBRYUploader: !useLBRYUploader })}
|
onChange={event => updatePublishForm({ useLBRYUploader: !useLBRYUploader })}
|
||||||
label={
|
label={
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{__('Automagically upload to your youtube channel!')}{' '}
|
{__('Automagically upload to your youtube channel.')}{' '}
|
||||||
<Button button="link" href="https://lbry.com/faq/lbry-uploader" label={__('Learn More')} />
|
<Button button="link" href="https://lbry.com/faq/lbry-uploader" label={__('Learn More')} />
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
{useLBRYUploader && (
|
||||||
|
<div className="section__actions">
|
||||||
|
{needsYTAuth ? (
|
||||||
|
<Button
|
||||||
|
button="primary"
|
||||||
|
onClick={signup}
|
||||||
|
label={__('Sign In With YouTube')}
|
||||||
|
disabled={false}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Button button="alt" onClick={unlink} label={__('Unlink YouTube Channel')} disabled={false} />
|
||||||
)}
|
)}
|
||||||
{!IS_WEB && useLBRYUploader && !needsYTAuth && isLBRYFirstUser && (
|
{ytError && <ErrorText>{__('There was an error with LBRY first publishing.')}</ErrorText>}
|
||||||
<div className="card__actions">
|
|
||||||
<Button button="primary" onClick={unlink} label="Unlink YouTube Channel!" disabled={false} />
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!IS_WEB && useLBRYUploader && needsYTAuth && isLBRYFirstUser && (
|
</>
|
||||||
<div className="card__actions">
|
|
||||||
<Button button="primary" onClick={signup} label="Sign in with YouTube!" disabled={false} />
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="section">
|
||||||
<FormField
|
<FormField
|
||||||
label={__('Language')}
|
label={__('Language')}
|
||||||
type="select"
|
type="select"
|
||||||
|
@ -169,9 +191,10 @@ function PublishAdditionalOptions(props: Props) {
|
||||||
handleLicenseUrlChange={event => updatePublishForm({ licenseUrl: event.target.value })}
|
handleLicenseUrlChange={event => updatePublishForm({ licenseUrl: event.target.value })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="card__actions">
|
<div className="section__actions">
|
||||||
<Button
|
<Button
|
||||||
label={hideSection ? __('Additional Options') : __('Hide')}
|
label={hideSection ? __('Additional Options') : __('Hide')}
|
||||||
button="link"
|
button="link"
|
||||||
|
|
|
@ -6391,9 +6391,9 @@ lbry-redux@lbryio/lbry-redux#67d8540ccc0fbedf018ae0bdfe3cae17660a5a6c:
|
||||||
reselect "^3.0.0"
|
reselect "^3.0.0"
|
||||||
uuid "^3.3.2"
|
uuid "^3.3.2"
|
||||||
|
|
||||||
lbryinc@lbryio/lbryinc#0f6fd2c33812fb1c1e393dd35b1a7560d3ba3fe2:
|
lbryinc@lbryio/lbryinc#cff5dd60934c4c6080e135f47ebbece1548c658c:
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/0f6fd2c33812fb1c1e393dd35b1a7560d3ba3fe2"
|
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/cff5dd60934c4c6080e135f47ebbece1548c658c"
|
||||||
dependencies:
|
dependencies:
|
||||||
reselect "^3.0.0"
|
reselect "^3.0.0"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue