Make the safe as and open file dialogs blocking (#2712)

This commit is contained in:
absidue 2022-10-14 08:00:23 +02:00 committed by GitHub
parent 3aa080d707
commit ad01d2b37d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 19 deletions

View File

@ -433,22 +433,28 @@ function runApp() {
return app.getPath('pictures')
})
ipcMain.handle(IpcChannels.SHOW_OPEN_DIALOG, async (_, options) => {
ipcMain.handle(IpcChannels.SHOW_OPEN_DIALOG, async ({ sender }, options) => {
const senderWindow = findSenderWindow(sender)
if (senderWindow) {
return await dialog.showOpenDialog(senderWindow, options)
}
return await dialog.showOpenDialog(options)
})
ipcMain.handle(IpcChannels.SHOW_SAVE_DIALOG, async (event, { options, useModal }) => {
if (useModal) {
const senderWindow = BrowserWindow.getAllWindows().find((window) => {
return window.webContents.id === event.sender.id
})
ipcMain.handle(IpcChannels.SHOW_SAVE_DIALOG, async ({ sender }, options) => {
const senderWindow = findSenderWindow(sender)
if (senderWindow) {
return await dialog.showSaveDialog(senderWindow, options)
}
}
return await dialog.showSaveDialog(options)
})
function findSenderWindow(sender) {
return BrowserWindow.getAllWindows().find((window) => {
return window.webContents.id === sender.id
})
}
ipcMain.on(IpcChannels.STOP_POWER_SAVE_BLOCKER, (_, id) => {
powerSaveBlocker.stop(id)
})

View File

@ -503,7 +503,7 @@ export default Vue.extend({
]
}
const response = await this.showSaveDialog({ options })
const response = await this.showSaveDialog(options)
if (response.canceled || response.filePath === '') {
// User canceled the save dialog
return
@ -580,7 +580,7 @@ export default Vue.extend({
return object
})
const response = await this.showSaveDialog({ options })
const response = await this.showSaveDialog(options)
if (response.canceled || response.filePath === '') {
// User canceled the save dialog
return
@ -628,7 +628,7 @@ export default Vue.extend({
}
})
const response = await this.showSaveDialog({ options })
const response = await this.showSaveDialog(options)
if (response.canceled || response.filePath === '') {
// User canceled the save dialog
return
@ -670,7 +670,7 @@ export default Vue.extend({
exportText += `${channel.id},${channelUrl},${channelName}\n`
})
exportText += '\n'
const response = await this.showSaveDialog({ options })
const response = await this.showSaveDialog(options)
if (response.canceled || response.filePath === '') {
// User canceled the save dialog
return
@ -719,7 +719,7 @@ export default Vue.extend({
newPipeObject.subscriptions.push(subscription)
})
const response = await this.showSaveDialog({ options })
const response = await this.showSaveDialog(options)
if (response.canceled || response.filePath === '') {
// User canceled the save dialog
return
@ -823,7 +823,7 @@ export default Vue.extend({
]
}
const response = await this.showSaveDialog({ options })
const response = await this.showSaveDialog(options)
if (response.canceled || response.filePath === '') {
// User canceled the save dialog
return
@ -978,7 +978,7 @@ export default Vue.extend({
]
}
const response = await this.showSaveDialog({ options })
const response = await this.showSaveDialog(options)
if (response.canceled || response.filePath === '') {
// User canceled the save dialog
return

View File

@ -1379,7 +1379,7 @@ export default Vue.extend({
]
}
const response = await this.showSaveDialog({ options, useModal: true })
const response = await this.showSaveDialog(options)
if (wasPlaying) {
this.player.play()
}

View File

@ -344,10 +344,10 @@ const actions = {
return await invokeIRC(context, IpcChannels.SHOW_OPEN_DIALOG, webCbk, options)
},
async showSaveDialog (context, { options, useModal = false }) {
async showSaveDialog (context, options) {
// TODO: implement showSaveDialog web compatible callback
const webCbk = () => null
return await invokeIRC(context, IpcChannels.SHOW_SAVE_DIALOG, webCbk, { options, useModal })
return await invokeIRC(context, IpcChannels.SHOW_SAVE_DIALOG, webCbk, options)
},
async getUserDataPath (context) {