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

View file

@ -144,7 +144,7 @@ class WalletBackup extends React.PureComponent<Props, State> {
label={__('Create Backup')}
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>
</React.Fragment>
}

View file

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

View file

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