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,86 +103,98 @@ 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
|
||||||
|
checked={useLBRYUploader}
|
||||||
|
type="checkbox"
|
||||||
|
name="use_lbry_uploader_checkbox"
|
||||||
|
onChange={event => updatePublishForm({ useLBRYUploader: !useLBRYUploader })}
|
||||||
|
label={
|
||||||
|
<React.Fragment>
|
||||||
|
{__('Automagically upload to your youtube channel.')}{' '}
|
||||||
|
<Button button="link" href="https://lbry.com/faq/lbry-uploader" label={__('Learn More')} />
|
||||||
|
</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} />
|
||||||
|
)}
|
||||||
|
{ytError && <ErrorText>{__('There was an error with LBRY first publishing.')}</ErrorText>}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="section">
|
||||||
<FormField
|
<FormField
|
||||||
type="checkbox"
|
label={__('Language')}
|
||||||
name="use_lbry_uploader_checkbox"
|
type="select"
|
||||||
onChange={event => updatePublishForm({ useLBRYUploader: !useLBRYUploader })}
|
name="content_language"
|
||||||
label={
|
value={language}
|
||||||
<React.Fragment>
|
onChange={event => updatePublishForm({ language: event.target.value })}
|
||||||
{__('Automagically upload to your youtube channel!')}{' '}
|
>
|
||||||
<Button button="link" href="https://lbry.com/faq/lbry-uploader" label={__('Learn More')} />
|
<option value="en">{__('English')}</option>
|
||||||
</React.Fragment>
|
<option value="zh">{__('Chinese')}</option>
|
||||||
}
|
<option value="fr">{__('French')}</option>
|
||||||
/>
|
<option value="de">{__('German')}</option>
|
||||||
)}
|
<option value="jp">{__('Japanese')}</option>
|
||||||
{!IS_WEB && useLBRYUploader && !needsYTAuth && isLBRYFirstUser && (
|
<option value="ru">{__('Russian')}</option>
|
||||||
<div className="card__actions">
|
<option value="es">{__('Spanish')}</option>
|
||||||
<Button button="primary" onClick={unlink} label="Unlink YouTube Channel!" disabled={false} />
|
<option value="id">{__('Indonesian')}</option>
|
||||||
</div>
|
<option value="fi">{__('Finnish')}</option>
|
||||||
)}
|
<option value="kn">{__('Kannada')}</option>
|
||||||
{!IS_WEB && useLBRYUploader && needsYTAuth && isLBRYFirstUser && (
|
<option value="it">{__('Italian')}</option>
|
||||||
<div className="card__actions">
|
<option value="nl">{__('Dutch')}</option>
|
||||||
<Button button="primary" onClick={signup} label="Sign in with YouTube!" disabled={false} />
|
<option value="tr">{__('Turkish')}</option>
|
||||||
</div>
|
<option value="pl">{__('Polish')}</option>
|
||||||
)}
|
<option value="ms">{__('Malay')}</option>
|
||||||
<FormField
|
<option value="pt">{__('Portuguese')}</option>
|
||||||
label={__('Language')}
|
<option value="vi">{__('Vietnamese')}</option>
|
||||||
type="select"
|
<option value="th">{__('Thai')}</option>
|
||||||
name="content_language"
|
<option value="ar">{__('Arabic')}</option>
|
||||||
value={language}
|
<option value="cs">{__('Czech')}</option>
|
||||||
onChange={event => updatePublishForm({ language: event.target.value })}
|
<option value="hr">{__('Croatian')}</option>
|
||||||
>
|
<option value="km">{__('Khmer')}</option>
|
||||||
<option value="en">{__('English')}</option>
|
<option value="ko">{__('Korean')}</option>
|
||||||
<option value="zh">{__('Chinese')}</option>
|
<option value="no">{__('Norwegian')}</option>
|
||||||
<option value="fr">{__('French')}</option>
|
<option value="ro">{__('Romanian')}</option>
|
||||||
<option value="de">{__('German')}</option>
|
<option value="hi">{__('Hindi')}</option>
|
||||||
<option value="jp">{__('Japanese')}</option>
|
<option value="el">{__('Greek')}</option>
|
||||||
<option value="ru">{__('Russian')}</option>
|
</FormField>
|
||||||
<option value="es">{__('Spanish')}</option>
|
|
||||||
<option value="id">{__('Indonesian')}</option>
|
|
||||||
<option value="fi">{__('Finnish')}</option>
|
|
||||||
<option value="kn">{__('Kannada')}</option>
|
|
||||||
<option value="it">{__('Italian')}</option>
|
|
||||||
<option value="nl">{__('Dutch')}</option>
|
|
||||||
<option value="tr">{__('Turkish')}</option>
|
|
||||||
<option value="pl">{__('Polish')}</option>
|
|
||||||
<option value="ms">{__('Malay')}</option>
|
|
||||||
<option value="pt">{__('Portuguese')}</option>
|
|
||||||
<option value="vi">{__('Vietnamese')}</option>
|
|
||||||
<option value="th">{__('Thai')}</option>
|
|
||||||
<option value="ar">{__('Arabic')}</option>
|
|
||||||
<option value="cs">{__('Czech')}</option>
|
|
||||||
<option value="hr">{__('Croatian')}</option>
|
|
||||||
<option value="km">{__('Khmer')}</option>
|
|
||||||
<option value="ko">{__('Korean')}</option>
|
|
||||||
<option value="no">{__('Norwegian')}</option>
|
|
||||||
<option value="ro">{__('Romanian')}</option>
|
|
||||||
<option value="hi">{__('Hindi')}</option>
|
|
||||||
<option value="el">{__('Greek')}</option>
|
|
||||||
</FormField>
|
|
||||||
|
|
||||||
<LicenseType
|
<LicenseType
|
||||||
licenseType={licenseType}
|
licenseType={licenseType}
|
||||||
otherLicenseDescription={otherLicenseDescription}
|
otherLicenseDescription={otherLicenseDescription}
|
||||||
licenseUrl={licenseUrl}
|
licenseUrl={licenseUrl}
|
||||||
handleLicenseChange={(newLicenseType, newLicenseUrl) =>
|
handleLicenseChange={(newLicenseType, newLicenseUrl) =>
|
||||||
updatePublishForm({
|
updatePublishForm({
|
||||||
licenseType: newLicenseType,
|
licenseType: newLicenseType,
|
||||||
licenseUrl: newLicenseUrl,
|
licenseUrl: newLicenseUrl,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
handleLicenseDescriptionChange={event =>
|
handleLicenseDescriptionChange={event =>
|
||||||
updatePublishForm({
|
updatePublishForm({
|
||||||
otherLicenseDescription: event.target.value,
|
otherLicenseDescription: event.target.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
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