Update to Electron 17, fix deleting drop-in mods from the settings view.

This commit is contained in:
Daniel Scalzi
2022-03-04 00:02:52 -05:00
parent ccf099a5cf
commit 15fc12b625
5 changed files with 104 additions and 82 deletions

View File

@@ -1,6 +1,7 @@
const fs = require('fs-extra')
const path = require('path')
const { shell } = require('electron')
const { ipcRenderer, shell } = require('electron')
const { SHELL_OPCODE } = require('./ipcconstants')
// Group #1: File Name (without .disabled, if any)
// Group #2: File Extension (jar, zip, or litemod)
@@ -95,14 +96,16 @@ exports.addDropinMods = function(files, modsdir) {
* @returns {Promise.<boolean>} True if the mod was deleted, otherwise false.
*/
exports.deleteDropinMod = async function(modsDir, fullName){
try {
await shell.trashItem(path.join(modsDir, fullName))
return true
} catch(error) {
const res = await ipcRenderer.invoke(SHELL_OPCODE.TRASH_ITEM, path.join(modsDir, fullName))
if(!res.result) {
shell.beep()
console.error('Error deleting drop-in mod.', error)
console.error('Error deleting drop-in mod.', res.error)
return false
}
return true
}
/**

View File

@@ -22,3 +22,7 @@ exports.MSFT_ERROR = {
ALREADY_OPEN: 'MSFT_AUTH_ERR_ALREADY_OPEN',
NOT_FINISHED: 'MSFT_AUTH_ERR_NOT_FINISHED'
}
exports.SHELL_OPCODE = {
TRASH_ITEM: 'TRASH_ITEM'
}