rc fixes for electron 9

This commit is contained in:
Sean Yesmunt 2020-10-15 19:06:05 -04:00
parent ba786fa50e
commit cfd4e8a05d
4 changed files with 19 additions and 8 deletions

View file

@ -1,6 +1,6 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import { remote } from 'electron';
import Button from 'component/button'; import Button from 'component/button';
import { FormField } from 'component/common/form'; import { FormField } from 'component/common/form';
@ -49,11 +49,22 @@ class FileSelector extends React.PureComponent<Props> {
} }
const file = files[0]; const file = files[0];
if (this.props.onFileChosen) { if (this.props.onFileChosen) {
this.props.onFileChosen(file); this.props.onFileChosen(file);
} }
}; };
handleDirectoryInputSelection = () => {
remote.dialog.showOpenDialog({ properties: ['openDirectory'] }).then(result => {
const path = result && result.filePaths[0];
if (path) {
// $FlowFixMe
this.props.onFileChosen({ path });
}
});
};
fileInputButton = () => { fileInputButton = () => {
this.fileInput.current.click(); this.fileInput.current.click();
}; };
@ -80,7 +91,7 @@ class FileSelector extends React.PureComponent<Props> {
autoFocus={autoFocus} autoFocus={autoFocus}
button="secondary" button="secondary"
disabled={disabled} disabled={disabled}
onClick={this.fileInputButton} onClick={type === 'openDirectory' ? this.handleDirectoryInputSelection : this.fileInputButton}
label={__('Browse')} label={__('Browse')}
/> />
} }
@ -90,7 +101,7 @@ class FileSelector extends React.PureComponent<Props> {
style={{ display: 'none' }} style={{ display: 'none' }}
accept={accept} accept={accept}
ref={this.fileInput} ref={this.fileInput}
onChange={() => this.handleFileInputSelection()} onChange={() => (type === 'openDirectory' ? () => {} : this.handleFileInputSelection())}
webkitdirectory={type === 'openDirectory' ? 'True' : null} webkitdirectory={type === 'openDirectory' ? 'True' : null}
/> />
</React.Fragment> </React.Fragment>

View file

@ -144,7 +144,7 @@ class WalletBackup extends React.PureComponent<Props, State> {
label={__('Create Backup')} label={__('Create Backup')}
onClick={() => this.backupWalletDir(lbryumWalletDir)} onClick={() => this.backupWalletDir(lbryumWalletDir)}
/> />
<Button button="link" label={__('Open Folder')} onClick={() => shell.openItem(lbryumWalletDir)} /> <Button button="link" label={__('Open Folder')} onClick={() => shell.openPath(lbryumWalletDir)} />
</div> </div>
</React.Fragment> </React.Fragment>
} }

View file

@ -89,9 +89,9 @@ class HelpPage extends React.PureComponent<Props, State> {
const logFileName = 'lbrynet.log'; const logFileName = 'lbrynet.log';
const os = this.state.versionInfo.os_system; const os = this.state.versionInfo.os_system;
if (os === 'Darwin' || os === 'Linux') { if (os === 'Darwin' || os === 'Linux') {
shell.openItem(`${userHomeDirectory}/${logFileName}`); shell.openPath(`${userHomeDirectory}/${logFileName}`);
} else { } else {
shell.openItem(`${userHomeDirectory}\\${logFileName}`); shell.openPath(`${userHomeDirectory}\\${logFileName}`);
} }
} }
@ -202,7 +202,7 @@ class HelpPage extends React.PureComponent<Props, State> {
button="secondary" button="secondary"
label={__('Open Log Folder')} label={__('Open Log Folder')}
icon={ICONS.OPEN_LOG_FOLDER} icon={ICONS.OPEN_LOG_FOLDER}
onClick={() => shell.openItem(dataDirectory)} onClick={() => shell.openPath(dataDirectory)}
/> />
</div> </div>
} }

View file

@ -23,7 +23,7 @@ export function doOpenFileInFolder(path) {
export function doOpenFileInShell(path) { export function doOpenFileInShell(path) {
return dispatch => { return dispatch => {
const success = shell.openItem(path); const success = shell.openPath(path);
if (!success) { if (!success) {
dispatch(doOpenFileInFolder(path)); dispatch(doOpenFileInFolder(path));
} }