// @flow import { SITE_NAME, SIMPLE_SITE, SITE_HELP_EMAIL } from 'config'; import * as ICONS from 'constants/icons'; import * as PAGES from 'constants/pages'; import * as React from 'react'; // @if TARGET='app' import { shell } from 'electron'; import WalletBackup from 'component/walletBackup'; // @endif import Lbry from 'lbry'; import Native from 'native'; import Button from 'component/button'; import Page from 'component/page'; import Card from 'component/common/card'; import I18nMessage from 'component/i18nMessage'; 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.openPath(`${userHomeDirectory}/${logFileName}`); } else { shell.openPath(`${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.com/get/lbry.dmg'; } else if (process.env.APPIMAGE !== undefined) { platform = `Linux (AppImage)`; newVerLink = 'https://lbry.com/get/lbry.AppImage'; } else if (ver.os_system === 'Linux') { platform = `Linux (${ver.platform})`; newVerLink = 'https://lbry.com/get/lbry.deb'; } else { platform = `Windows (${ver.platform})`; newVerLink = 'https://lbry.com/get/lbry.msi'; } } else { ver = null; } return ( {SIMPLE_SITE ? (