Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unnecessary setupDialogProperties #28982

Merged
merged 1 commit into from
May 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 2 additions & 17 deletions lib/browser/api/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down