Skip to content

Commit

Permalink
Merge branch 'dev' into release-2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Nov 1, 2021
2 parents 3813b10 + 1eda835 commit 59ea52f
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/app-desktop/InteropServiceHelper.ts
Expand Up @@ -153,12 +153,12 @@ export default class InteropServiceHelper {

if (module.target === 'file') {
const noteId = options.sourceNoteIds && options.sourceNoteIds.length ? options.sourceNoteIds[0] : null;
path = bridge().showSaveDialog({
path = await bridge().showSaveDialog({
filters: [{ name: module.description, extensions: module.fileExtensions }],
defaultPath: await this.defaultFilename(noteId, module.fileExtensions[0]),
});
} else {
path = bridge().showOpenDialog({
path = await bridge().showOpenDialog({
properties: ['openDirectory', 'createDirectory'],
});
}
Expand Down
8 changes: 4 additions & 4 deletions packages/app-desktop/bridge.ts
Expand Up @@ -125,25 +125,25 @@ export class Bridge {
return this.window().webContents.closeDevTools();
}

showSaveDialog(options: any) {
async showSaveDialog(options: any) {
const { dialog } = require('electron');
if (!options) options = {};
if (!('defaultPath' in options) && this.lastSelectedPaths_.file) options.defaultPath = this.lastSelectedPaths_.file;
const filePath = dialog.showSaveDialogSync(this.window(), options);
const { filePath } = await dialog.showSaveDialog(this.window(), options);
if (filePath) {
this.lastSelectedPaths_.file = filePath;
}
return filePath;
}

showOpenDialog(options: any = null) {
async showOpenDialog(options: any = null) {
const { dialog } = require('electron');
if (!options) options = {};
let fileType = 'file';
if (options.properties && options.properties.includes('openDirectory')) fileType = 'directory';
if (!('defaultPath' in options) && this.lastSelectedPaths_[fileType]) options.defaultPath = this.lastSelectedPaths_[fileType];
if (!('createDirectory' in options)) options.createDirectory = true;
const filePaths = dialog.showOpenDialogSync(this.window(), options);
const { filePaths } = await dialog.showOpenDialog(this.window(), options);
if (filePaths && filePaths.length) {
this.lastSelectedPaths_[fileType] = dirname(filePaths[0]);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app-desktop/gui/ConfigScreen/ConfigScreen.tsx
Expand Up @@ -481,8 +481,8 @@ class ConfigScreenComponent extends React.Component<any, any> {
updateSettingValue(key, joinCmd(cmd));
};

const browseButtonClick = () => {
const paths = bridge().showOpenDialog();
const browseButtonClick = async () => {
const paths = await bridge().showOpenDialog();
if (!paths || !paths.length) return;
const cmd = splitCmd(this.state.settings[key]);
cmd[0] = paths[0];
Expand Down
Expand Up @@ -181,7 +181,7 @@ export default function(props: Props) {
}, [pluginSettings, props.onChange]);

const onInstall = useCallback(async () => {
const result = bridge().showOpenDialog({
const result = await bridge().showOpenDialog({
filters: [{ name: 'Joplin Plugin Archive', extensions: ['jpl'] }],
});

Expand Down
4 changes: 2 additions & 2 deletions packages/app-desktop/gui/KeymapConfig/KeymapConfigScreen.tsx
Expand Up @@ -50,7 +50,7 @@ export const KeymapConfigScreen = ({ themeId }: KeymapConfigScreenProps) => {
};

const handleImport = async () => {
const filePath = bridge().showOpenDialog({
const filePath = await bridge().showOpenDialog({
properties: ['openFile'],
defaultPath: 'keymap-desktop',
filters: [{ name: 'Joplin Keymaps (keymap-desktop.json)', extensions: ['json'] }],
Expand All @@ -68,7 +68,7 @@ export const KeymapConfigScreen = ({ themeId }: KeymapConfigScreenProps) => {
};

const handleExport = async () => {
const filePath = bridge().showSaveDialog({
const filePath = await bridge().showSaveDialog({
defaultPath: 'keymap-desktop',
filters: [{ name: 'Joplin Keymaps (keymap-desktop.json)', extensions: ['json'] }],
});
Expand Down
4 changes: 2 additions & 2 deletions packages/app-desktop/gui/MainScreen/commands/exportPdf.ts
Expand Up @@ -20,12 +20,12 @@ export const runtime = (comp: any): CommandRuntime => {

let path = null;
if (noteIds.length === 1) {
path = bridge().showSaveDialog({
path = await bridge().showSaveDialog({
filters: [{ name: _('PDF File'), extensions: ['pdf'] }],
defaultPath: await InteropServiceHelper.defaultFilename(noteIds[0], 'pdf'),
});
} else {
path = bridge().showOpenDialog({
path = await bridge().showOpenDialog({
properties: ['openDirectory', 'createDirectory'],
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app-desktop/gui/MenuBar.tsx
Expand Up @@ -180,11 +180,11 @@ function useMenu(props: Props) {
let path = null;

if (moduleSource === 'file') {
path = bridge().showOpenDialog({
path = await bridge().showOpenDialog({
filters: [{ name: module.description, extensions: module.fileExtensions }],
});
} else {
path = bridge().showOpenDialog({
path = await bridge().showOpenDialog({
properties: ['openDirectory', 'createDirectory'],
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/app-desktop/gui/NoteEditor/utils/contextMenu.ts
Expand Up @@ -107,7 +107,7 @@ export function menuItems(dispatch: Function): ContextMenuItems {
label: _('Save as...'),
onAction: async (options: ContextMenuOptions) => {
const { resourcePath, resource } = await resourceInfo(options);
const filePath = bridge().showSaveDialog({
const filePath = await bridge().showSaveDialog({
defaultPath: resource.filename ? resource.filename : resource.title,
});
if (!filePath) return;
Expand Down
Expand Up @@ -65,7 +65,7 @@ export async function commandAttachFileToBody(body: string, filePaths: string[]
};

if (!filePaths) {
filePaths = bridge().showOpenDialog({
filePaths = await bridge().showOpenDialog({
properties: ['openFile', 'createDirectory', 'multiSelections'],
});
if (!filePaths || !filePaths.length) return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/app-desktop/gui/StatusScreen/StatusScreen.tsx
Expand Up @@ -25,7 +25,7 @@ const StyledAdvancedToolItem = styled.div`
async function exportDebugReportClick() {
const filename = `syncReport-${new Date().getTime()}.csv`;

const filePath = bridge().showSaveDialog({
const filePath = await bridge().showSaveDialog({
title: _('Please select where the sync status should be exported to'),
defaultPath: filename,
});
Expand Down

0 comments on commit 59ea52f

Please sign in to comment.