From cfd4e8a05dd8e9430c7efc5d7d6b19e83879aeb3 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 15 Oct 2020 19:06:05 -0400 Subject: [PATCH] rc fixes for electron 9 --- ui/component/common/file-selector.jsx | 17 ++++++++++++++--- ui/component/walletBackup/view.jsx | 2 +- ui/page/help/view.jsx | 6 +++--- ui/redux/actions/file.js | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ui/component/common/file-selector.jsx b/ui/component/common/file-selector.jsx index ea298efc8..9341b0952 100644 --- a/ui/component/common/file-selector.jsx +++ b/ui/component/common/file-selector.jsx @@ -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 { } 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 { 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 { style={{ display: 'none' }} accept={accept} ref={this.fileInput} - onChange={() => this.handleFileInputSelection()} + onChange={() => (type === 'openDirectory' ? () => {} : this.handleFileInputSelection())} webkitdirectory={type === 'openDirectory' ? 'True' : null} /> diff --git a/ui/component/walletBackup/view.jsx b/ui/component/walletBackup/view.jsx index aa25c3d1c..3592cbdfb 100644 --- a/ui/component/walletBackup/view.jsx +++ b/ui/component/walletBackup/view.jsx @@ -144,7 +144,7 @@ class WalletBackup extends React.PureComponent { label={__('Create Backup')} onClick={() => this.backupWalletDir(lbryumWalletDir)} /> -