Skip to content

Commit

Permalink
fix: execute the renderer even when the path has spaces (#37)
Browse files Browse the repository at this point in the history
fix: error on executing the renderer was triggering a reload without showing the error
fix: on error on executing we're not going to hide the renderer
feat: added ELECTRON_MODE and ROLLOUTS['@dcl/explorer-desktop'] to the global variables to use from other systems
  • Loading branch information
kuruk-mm authored Feb 9, 2022
1 parent 1984496 commit 47d0e00
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
11 changes: 7 additions & 4 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,18 @@ const startApp = async (): Promise<void> => {
onOpenUrl(url, win)
});

ipcMain.on('process-terminated', async (event) => {
ipcMain.on('process-terminated', async (event, reloadWebsite: boolean) => {
main.isRendererOpen = false

// (#1457) we should reload the url
loadDecentralandWeb(win)
if (reloadWebsite) {
// (#1457) we should reload the url
loadDecentralandWeb(win)
}

showWindowAndHideTray(win)
})

ipcMain.on('executeProcess', (event) => {
ipcMain.on('on-open-renderer', (event) => {
main.isRendererOpen = true
hideWindowInTray(win)
})
Expand Down
28 changes: 21 additions & 7 deletions electron/updater.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as electronDl from 'electron-dl'
import { unzip } from './decompress'
import { BrowserWindow, ipcMain, ipcRenderer } from 'electron'
import { BrowserWindow, ipcMain } from 'electron'
import * as fs from 'fs'
import axios from 'axios'
import { main } from './main'
import * as isDev from 'electron-is-dev'

let remoteVersion: string

Expand All @@ -21,6 +22,12 @@ const getCurrentVersion = (rendererPath: string, versionPath: string): string |

const registerVersionEvent = (launcherPaths: LauncherPaths) => {
ipcMain.on('checkVersion', async (event) => {

const electronMode = `\"${main.config.developerMode || isDev ? 'development' : 'production'}\"`
event.sender.executeJavaScript(
`ELECTRON_MODE = ${electronMode}`
)

const version = getCurrentVersion(launcherPaths.rendererPath, launcherPaths.versionPath)
const url = launcherPaths.baseUrl + main.config.desktopBranch + launcherPaths.remoteVersionUrl

Expand All @@ -44,9 +51,13 @@ const registerVersionEvent = (launcherPaths: LauncherPaths) => {
}

if (validVersion) {
const desktopVersion = `\"desktop-${main.config.desktopBranch}.commit-${remoteVersion.substring(0, 7)}\"`
event.sender.executeJavaScript(
`globalThis.ROLLOUTS['@dcl/unity-renderer']['version'] = ${desktopVersion};`
)

event.sender.executeJavaScript(
`globalThis.ROLLOUTS['@dcl/unity-renderer']['version'] = \"desktop-${main.config.desktopBranch
}.commit-${remoteVersion.substr(0, 7)}\";`
`globalThis.ROLLOUTS['@dcl/explorer-desktop'] = { 'version': ${desktopVersion} };`
)
}
})
Expand All @@ -60,17 +71,18 @@ const registerExecuteProcessEvent = (rendererPath: string, executablePath: strin
ipcMain.on('executeProcess', (event) => {
try {
const onExecute = (err: any, data: any) => {
console.log("Process terminated - " + data.toString())
ipcMain.emit("process-terminated");

if (err) {
console.error('Execute error: ', err)
event.sender.send('downloadState', { type: 'ERROR', message: err })
ipcMain.emit("process-terminated", false);
return
}

console.log("Process terminated - " + data.toString())
ipcMain.emit("process-terminated", true);
}

let path = rendererPath + getBranchName() + executablePath
let path = "\"" + rendererPath + getBranchName() + executablePath + "\""

let extraParams = ` --browser false --port ${main.config.port}`

Expand All @@ -83,6 +95,8 @@ const registerExecuteProcessEvent = (rendererPath: string, executablePath: strin
const { exec } = require('child_process')
exec(path + extraParams, onExecute)
}

ipcMain.emit("on-open-renderer")
} catch (e) {
console.error('Execute error: ', e)
event.sender.send('downloadState', { type: 'ERROR', message: e })
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "explorer-desktop-launcher",
"version": "0.1.26",
"version": "0.1.27",
"author": "decentraland",
"description": "Decentraland Desktop Launcher",
"homepage": ".",
Expand Down

0 comments on commit 47d0e00

Please sign in to comment.