// @TODO: Customize advice based on OS // @flow import * as icons from 'constants/icons'; import * as React from 'react'; // @if TARGET='app' import { shell } from 'electron'; // @endif import { Lbry } from 'lbry-redux'; import Native from 'native'; import Button from 'component/button'; import Page from 'component/page'; type DeamonSettings = { data_dir: string | any, }; type Props = { deamonSettings: DeamonSettings, accessToken: string, fetchAccessToken: () => void, doAuth: () => void, user: any, }; type VersionInfo = { os_system: string, os_release: string, platform: string, lbrynet_version: string, }; type State = { versionInfo: VersionInfo | any, lbryId: String | any, uiVersion: ?string, upgradeAvailable: ?boolean, accessTokenHidden: ?boolean, }; class HelpPage extends React.PureComponent { constructor(props: Props) { super(props); this.state = { versionInfo: null, lbryId: null, uiVersion: null, upgradeAvailable: null, accessTokenHidden: true, }; (this: any).showAccessToken = this.showAccessToken.bind(this); (this: any).openLogFile = this.openLogFile.bind(this); } componentDidMount() { // @if TARGET='app' Native.getAppVersionInfo().then(({ localVersion, upgradeAvailable }) => { this.setState({ uiVersion: localVersion, upgradeAvailable, }); }); if (!this.props.accessToken) this.props.fetchAccessToken(); // @endif Lbry.version().then(info => { this.setState({ versionInfo: info, }); }); Lbry.status().then(info => { this.setState({ lbryId: info.installation_id, }); }); } showAccessToken() { this.setState({ accessTokenHidden: false, }); } openLogFile(userHomeDirectory: string) { const logFileName = 'lbrynet.log'; const os = this.state.versionInfo.os_system; if (os === 'Darwin' || os === 'Linux') { shell.openItem(`${userHomeDirectory}/${logFileName}`); } else { shell.openItem(`${userHomeDirectory}\\${logFileName}`); } } render() { let ver; let osName; let platform; let newVerLink; const { accessToken, doAuth, user, deamonSettings } = this.props; const { data_dir: dataDirectory } = deamonSettings; if (this.state.versionInfo) { ver = this.state.versionInfo; if (ver.os_system === 'Darwin') { osName = parseInt(ver.os_release.match(/^\d+/), 10) < 16 ? 'Mac OS X' : 'Mac OS'; platform = `${osName} ${ver.os_release}`; newVerLink = 'https://lbry.io/get/lbry.dmg'; } else if (ver.os_system === 'Linux') { platform = `Linux (${ver.platform})`; newVerLink = 'https://lbry.io/get/lbry.deb'; } else { platform = `Windows (${ver.platform})`; newVerLink = 'https://lbry.io/get/lbry.msi'; } } else { ver = null; } return (

{__('Read the FAQ')}

{__('Our FAQ answers many common questions.')}

{__('Get Live Help')}

{__('Live help is available most hours in the')} #help{' '} {__('channel of our Discord chat room.')}

{__('View your Log')}

{__('Did something go wrong? Have a look in your log file, or send it to')}{' '}

{__('Report a Bug or Suggest a New Feature')}

{__('Did you find something wrong? Think LBRY could add something useful and cool?')}{' '}

{__('Thanks! LBRY is made by its users.')}

{__('About')}

{this.state.upgradeAvailable !== null && this.state.upgradeAvailable ? (

{__('A newer version of LBRY is available.')}{' '}

{__('App')} {this.state.uiVersion}
{__('Daemon (lbrynet)')} {ver ? ver.lbrynet_version : __('Loading')}
{__('Connected Email')} {user && user.primary_email ? ( {user.primary_email}{' '}
{__('Reward Eligible')} {user && user.is_reward_approved ? __('Yes') : __('No')}
{__('Platform')} {platform}
{__('Installation ID')} {this.state.lbryId}
{__('Access Token')} {this.state.accessTokenHidden && (
); } } export default HelpPage;