refactor: remove unnecessary setupDialogProperties (#28982)

This commit is contained in:
Milan Burda 2021-05-05 09:00:41 +02:00 committed by GitHub
parent 961b74b2ac
commit 42e5421276
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,11 +2,6 @@ import { app, BrowserWindow } from 'electron/main';
import type { OpenDialogOptions, OpenDialogReturnValue, MessageBoxOptions, SaveDialogOptions, SaveDialogReturnValue, MessageBoxReturnValue, CertificateTrustDialogOptions } from 'electron/main';
const dialogBinding = process._linkedBinding('electron_browser_dialog');
enum DialogType {
OPEN = 'OPEN',
SAVE = 'SAVE'
}
enum SaveFileDialogProperties {
createDirectory = 1 << 0,
showHiddenFiles = 1 << 1,
@ -72,16 +67,6 @@ const setupSaveDialogProperties = (properties: (keyof typeof SaveFileDialogPrope
return dialogProperties;
};
const setupDialogProperties = (type: DialogType, properties: string[]): number => {
if (type === DialogType.OPEN) {
return setupOpenDialogProperties(properties as (keyof typeof OpenFileDialogProperties)[]);
} else if (type === DialogType.SAVE) {
return setupSaveDialogProperties(properties as (keyof typeof SaveFileDialogProperties)[]);
} else {
return 0;
}
};
const saveDialog = (sync: boolean, window: BrowserWindow | null, options?: SaveDialogOptions) => {
checkAppInitialized();
@ -115,7 +100,7 @@ const saveDialog = (sync: boolean, window: BrowserWindow | null, options?: SaveD
nameFieldLabel,
showsTagField,
window,
properties: setupDialogProperties(DialogType.SAVE, properties)
properties: setupSaveDialogProperties(properties)
};
return sync ? dialogBinding.showSaveDialogSync(settings) : dialogBinding.showSaveDialog(settings);
@ -156,7 +141,7 @@ const openDialog = (sync: boolean, window: BrowserWindow | null, options?: OpenD
message,
securityScopedBookmarks,
window,
properties: setupDialogProperties(DialogType.OPEN, properties)
properties: setupOpenDialogProperties(properties)
};
return (sync) ? dialogBinding.showOpenDialogSync(settings) : dialogBinding.showOpenDialog(settings);