use default path in windows when choosing a file #7625

Merged
ByronEricPerez merged 2 commits from Minor_UI_issue-_Choose_File_opens_LBRY_install_folder_on_windows_#1811 into master 2022-06-28 21:49:41 +02:00
2 changed files with 24 additions and 2 deletions

View file

@ -47,7 +47,24 @@ class FileSelector extends React.PureComponent<Props> {
};
handleDirectoryInputSelection = () => {
remote.dialog.showOpenDialog({ properties: ['openDirectory'] }).then((result) => {
let defaultPath;
let properties;
let isWin = process.platform === 'win32';
let type = this.props.type;
if (isWin === true) {
defaultPath = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
}
if (type === 'openFile') {
properties = ['openFile'];
}
if (type === 'openDirectory') {
properties = ['openDirectory'];
}
remote.dialog.showOpenDialog({ properties, defaultPath }).then((result) => {
const path = result && result.filePaths[0];
jessopb commented 2022-06-24 22:24:13 +02:00 (Migrated from github.com)
Review

nice,
tested in console in linux
x = require('@electron/remote')
x.dialog.showOpenDialog({properties: ['openFile'], defaultPath: undefined})
And it worked fine.

nice, tested in console in linux `x = require('@electron/remote')` `x.dialog.showOpenDialog({properties: ['openFile'], defaultPath: undefined})` And it worked fine.
if (path) {
// $FlowFixMe
@ -82,7 +99,11 @@ class FileSelector extends React.PureComponent<Props> {
autoFocus={autoFocus}
button="primary"
disabled={disabled}
onClick={type === 'openDirectory' ? this.handleDirectoryInputSelection : this.fileInputButton}
onClick={
type === 'openDirectory' || type === 'openFile'
? this.handleDirectoryInputSelection
: this.fileInputButton
}
label={__('Browse')}
/>
}

View file

@ -325,6 +325,7 @@ function PublishFile(props: Props) {
{showFileUpload && (
<>
<FileSelector
type="openFile"
label={__('File')}
disabled={disabled}
currentPath={currentFile}