Skip to content

Commit

Permalink
Electron 13.
Browse files Browse the repository at this point in the history
Deleting drop-in mods seems to be broken. If you're having this issue,
please comment on this issue so electron fixes it.. electron/electron#29598
  • Loading branch information
dscalzi committed Jun 24, 2021
1 parent 61dbabd commit 2c487f7
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 450 deletions.
13 changes: 8 additions & 5 deletions app/assets/js/dropinmodutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,17 @@ exports.addDropinMods = function(files, modsdir) {
* @param {string} modsDir The path to the mods directory.
* @param {string} fullName The fullName of the discovered mod to delete.
*
* @returns {boolean} True if the mod was deleted, otherwise false.
* @returns {Promise.<boolean>} True if the mod was deleted, otherwise false.
*/
exports.deleteDropinMod = function(modsDir, fullName){
const res = shell.moveItemToTrash(path.join(modsDir, fullName))
if(!res){
exports.deleteDropinMod = async function(modsDir, fullName){
try {
await shell.trashItem(path.join(modsDir, fullName))
return true
} catch(error) {
shell.beep()
console.error('Error deleting drop-in mod.', error)
return false
}
return res
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/assets/js/scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,9 @@ function resolveDropinModsForUI(){
function bindDropinModsRemoveButton(){
const sEls = settingsModsContainer.querySelectorAll('[remmod]')
Array.from(sEls).map((v, index, arr) => {
v.onclick = () => {
v.onclick = async () => {
const fullName = v.getAttribute('remmod')
const res = DropinModUtil.deleteDropinMod(CACHE_SETTINGS_MODS_DIR, fullName)
const res = await DropinModUtil.deleteDropinMod(CACHE_SETTINGS_MODS_DIR, fullName)
if(res){
document.getElementById(fullName).remove()
} else {
Expand Down
11 changes: 3 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const fs = require('fs')
const isDev = require('./app/assets/js/isdev')
const path = require('path')
const semver = require('semver')
const url = require('url')
const { pathToFileURL } = require('url')

// Setup auto updater.
function initAutoUpdater(event, data) {
Expand Down Expand Up @@ -105,19 +105,14 @@ function createWindow() {
preload: path.join(__dirname, 'app', 'assets', 'js', 'preloader.js'),
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
worldSafeExecuteJavaScript: true
enableRemoteModule: true
},
backgroundColor: '#171614'
})

ejse.data('bkid', Math.floor((Math.random() * fs.readdirSync(path.join(__dirname, 'app', 'assets', 'images', 'backgrounds')).length)))

win.loadURL(url.format({
pathname: path.join(__dirname, 'app', 'app.ejs'),
protocol: 'file:',
slashes: true
}))
win.loadURL(pathToFileURL(path.join(__dirname, 'app', 'app.ejs')).toString())

/*win.once('ready-to-show', () => {
win.show()
Expand Down
Loading

0 comments on commit 2c487f7

Please sign in to comment.