From bb39b1a5f9f7dbf6561c403d64c4c9ece6ff2357 Mon Sep 17 00:00:00 2001 From: Mateo Miccino Date: Tue, 16 May 2023 15:16:02 -0300 Subject: [PATCH] refactor: remove manual auto update (#177) Co-authored-by: frami --- electron/main.ts | 59 +++++------------- electron/window.ts | 18 ++---- package-lock.json | 5 +- package.json | 5 +- public/new-version.html | 130 ---------------------------------------- 5 files changed, 25 insertions(+), 192 deletions(-) delete mode 100644 public/new-version.html diff --git a/electron/main.ts b/electron/main.ts index dbb5569..116148e 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -1,22 +1,13 @@ import { shell, app, BrowserWindow, ipcMain, Tray, Menu, crashReporter, systemPreferences } from 'electron' -import * as isDev from 'electron-is-dev' import { getOSName, getFreePort } from './updater' import { exit } from 'process' import { autoUpdater } from 'electron-updater' import { parseConfig } from './cmdParser' import { getAppTitle, getAppBasePath } from './helpers' -import { - createWindow, - hideWindowInTray, - loadDecentralandWeb, - onOpenUrl, - reportNewLauncherVersion, - showWindowAndHideTray -} from './window' +import { createWindow, hideWindowInTray, loadDecentralandWeb, onOpenUrl, showWindowAndHideTray } from './window' import { LauncherConfig, LauncherPaths } from './types' import { isTrustedCertificate } from './certificateChecker' import { reportError, initializeRollbar } from './rollbar' -import * as semver from 'semver' import fs = require('fs') const defaultConfig: LauncherConfig = { @@ -99,34 +90,16 @@ if (getOSName() === 'windows') { const checkUpdates = async (win: BrowserWindow): Promise => { try { - if (getOSName() === 'mac') { - // No updates in Mac until we signed the executable - const installedVersion = autoUpdater.currentVersion.version - autoUpdater.autoDownload = false - const result = await autoUpdater.checkForUpdates() - const newVersion = result?.updateInfo.version - console.log('Mac Result:', result) - console.log('Compare versions', installedVersion, 'vs', newVersion) - - if (newVersion && semver.lt(installedVersion, newVersion)) { - const macDownloadUrl = - 'https://github.com/decentraland/explorer-desktop-launcher/releases/latest/download/Decentraland.dmg' - await reportNewLauncherVersion(win, macDownloadUrl) - } else { - await loadDecentralandWeb(win) // Load decentraland web to report the error - } + const result = await autoUpdater.checkForUpdatesAndNotify() + console.log('Result:', result) + if (result === null || !result.downloadPromise) { + await loadDecentralandWeb(win) } else { - const result = await autoUpdater.checkForUpdatesAndNotify() - console.log('Result:', result) - if (result === null || !result.downloadPromise) { - await loadDecentralandWeb(win) - } else { - await result.downloadPromise - - console.log('Download completed') - const silent = process.platform === 'darwin' // Silent=true only on Mac - autoUpdater.quitAndInstall(silent, true) - } + await result.downloadPromise + + console.log('Download completed') + const silent = process.platform === 'darwin' // Silent=true only on Mac + autoUpdater.quitAndInstall(silent, true) } } catch (err) { console.error(`Check Updates error: ${err}`) @@ -202,7 +175,7 @@ const startApp = async (): Promise => { await checkUpdates(win) } - const microphoneResult = await askForMediaAccess('microphone'); + const microphoneResult = await askForMediaAccess('microphone') if (!microphoneResult) { console.log('Microphone permission was not given') } @@ -247,7 +220,7 @@ app function initializeCrashReport() { var path = getAppBasePath() - if (!fs.existsSync(path)) fs.mkdir(path, () => { }) + if (!fs.existsSync(path)) fs.mkdir(path, () => {}) app.setPath('crashDumps', path) @@ -257,12 +230,12 @@ function initializeCrashReport() { const askForMediaAccess = async (mediaType: 'microphone' | 'camera') => { if (systemPreferences.askForMediaAccess) { // Electron currently only implements this on macOS - const previous = await systemPreferences.getMediaAccessStatus(mediaType); - const result = await systemPreferences.askForMediaAccess(mediaType); - const next = await systemPreferences.getMediaAccessStatus(mediaType); + const previous = await systemPreferences.getMediaAccessStatus(mediaType) + const result = await systemPreferences.askForMediaAccess(mediaType) + const next = await systemPreferences.getMediaAccessStatus(mediaType) console.log(`MediaAccess for ${mediaType} is went from ${previous} to ${next} (askForMediaAccess: ${result})`) return result } // For other platforms we can't reasonably do anything other than assume we have access. - return true; + return true } diff --git a/electron/window.ts b/electron/window.ts index b501a03..f1c5378 100644 --- a/electron/window.ts +++ b/electron/window.ts @@ -55,12 +55,6 @@ export const loadDefaultWeb = async (win: BrowserWindow) => { await win.loadURL(`file://${__dirname}/../../public/index.html#v${app.getVersion()}`) } -export const reportNewLauncherVersion = async (win: BrowserWindow, updateUrl: string) => { - await win.loadURL(`file://${__dirname}/../../public/new-version.html`) - - win.webContents.send('setUrl', { url: updateUrl }) -} - export const checkDeveloperConsole = (win: BrowserWindow) => { if (isDev || main.config.developerMode) { win.webContents.openDevTools({ mode: 'detach' }) @@ -132,13 +126,11 @@ export const loadDecentralandWeb = async (win: BrowserWindow) => { const stage = main.config.developerMode ? 'zone' : 'org' const url = new URL(main.config.customUrl || `http://play.decentraland.${stage}/?`) - - if (main.config.desktopBranch) - url.searchParams.append('explorer-branch', main.config.desktopBranch) - - if (main.config.customDesktopVersion) - url.searchParams.append('explorer-version', main.config.customDesktopVersion) - + + if (main.config.desktopBranch) url.searchParams.append('explorer-branch', main.config.desktopBranch) + + if (main.config.customDesktopVersion) url.searchParams.append('explorer-version', main.config.customDesktopVersion) + const customParamObj = new URLSearchParams(main.config.customParams) for (const [key, value] of Array.from(customParamObj.entries())) { url.searchParams.append(key, value) diff --git a/package-lock.json b/package-lock.json index 394ef61..29c7f31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "explorer-desktop-launcher", - "version": "0.1.47", + "version": "0.1.52", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "explorer-desktop-launcher", - "version": "0.1.47", + "version": "0.1.52", "hasInstallScript": true, "dependencies": { "axios": "^1.2.2", @@ -17,7 +17,6 @@ "find-free-port": "^2.0.0", "node-stream-zip": "^1.15.0", "rollbar": "^2.26.1", - "semver": "^7.3.8", "web-vitals": "^1.1.2" }, "devDependencies": { diff --git a/package.json b/package.json index eb57a89..6269360 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "explorer-desktop-launcher", - "version": "0.1.51", + "version": "0.1.52", "author": "decentraland", "description": "Decentraland Desktop Launcher", "homepage": ".", @@ -15,7 +15,6 @@ "find-free-port": "^2.0.0", "node-stream-zip": "^1.15.0", "rollbar": "^2.26.1", - "semver": "^7.3.8", "web-vitals": "^1.1.2" }, "devDependencies": { @@ -142,4 +141,4 @@ "last 1 safari version" ] } -} +} \ No newline at end of file diff --git a/public/new-version.html b/public/new-version.html deleted file mode 100644 index 4b3e887..0000000 --- a/public/new-version.html +++ /dev/null @@ -1,130 +0,0 @@ - - - - - Decentraland - - - - - -
-
-

Update is available!

-
A new version of Decentraland Desktop is available. - Click on update and relaunch the application to continue.
-
- - - -
-
- -
-
- - - -