#1556 Checking for OS before opening the log file

This commit is contained in:
Amit Nandan P 2018-06-09 17:33:23 -05:00
parent d46c60da86
commit 4045fadc40

View file

@ -1,21 +1,36 @@
// @TODO: Customize advice based on OS // @TODO: Customize advice based on OS
import React from 'react'; // @flow
import * as React from 'react';
import { shell } from 'electron'; import { shell } from 'electron';
import { Lbry } from 'lbry-redux'; import { Lbry } from 'lbry-redux';
import Native from 'native'; import * as Native from 'native';
import Button from 'component/button'; import Button from 'component/button';
import BusyIndicator from 'component/common/busy-indicator'; import BusyIndicator from 'component/common/busy-indicator';
import Page from 'component/page'; import Page from 'component/page';
import * as icons from 'constants/icons'; import * as icons from 'constants/icons';
type Props = { type DeamonSettings = {
deamonSettings: { data_dir: string,
data_dir: ?string,
},
}; };
class HelpPage extends React.PureComponent { type Props = {
constructor(props) { deamonSettings: DeamonSettings,
accessToken: string,
fetchAccessToken: () => void,
doAuth: () => void,
user: any,
};
type State = {
versionInfo: any,
lbryId: any,
uiVersion: any,
upgradeAvailable: any,
accessTokenHidden: any,
};
class HelpPage extends React.PureComponent<Props, State> {
constructor(props: Props) {
super(props); super(props);
this.state = { this.state = {
@ -26,11 +41,12 @@ class HelpPage extends React.PureComponent {
accessTokenHidden: true, accessTokenHidden: true,
}; };
this.showAccessToken = this.showAccessToken.bind(this); (this: any).showAccessToken = this.showAccessToken.bind(this);
(this: any).openLogFile = this.openLogFile.bind(this);
} }
componentDidMount() { componentDidMount() {
Native.getAppVersionInfo().then(({ remoteVersion, localVersion, upgradeAvailable }) => { Native.getAppVersionInfo().then(({ localVersion, upgradeAvailable }) => {
this.setState({ this.setState({
uiVersion: localVersion, uiVersion: localVersion,
upgradeAvailable, upgradeAvailable,
@ -56,6 +72,16 @@ class HelpPage extends React.PureComponent {
}); });
} }
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() { render() {
let ver; let ver;
let osName; let osName;
@ -127,7 +153,7 @@ class HelpPage extends React.PureComponent {
button="primary" button="primary"
label={__('Open Log')} label={__('Open Log')}
icon={icons.REPORT} icon={icons.REPORT}
onClick={() => shell.openItem(`${dataDirectory}/lbrynet.log`)} onClick={() => this.openLogFile(dataDirectory)}
/> />
<Button <Button
button="primary" button="primary"