Fix autoupdate crash (nativeImage => NativeImage) #1425

This commit is contained in:
Ben Gotow 2019-03-21 17:20:50 -07:00
parent 6bd51c70f6
commit 590a746b1a

View file

@ -1,5 +1,5 @@
/* eslint global-require: 0*/ /* eslint global-require: 0*/
import { dialog, NativeImage } from 'electron'; import { dialog, nativeImage } from 'electron';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
@ -161,12 +161,10 @@ export default class AutoUpdateManager extends EventEmitter {
autoUpdater.quitAndInstall(); autoUpdater.quitAndInstall();
} }
iconURL() { dialogIcon() {
const url = path.join(process.resourcesPath, 'static', 'images', 'mailspring.png'); const iconPath = path.join(global.application.resourcePath, 'static', 'images', 'mailspring.png');
if (!fs.existsSync(url)) { if (!fs.existsSync(iconPath)) return undefined;
return undefined; return nativeImage.createFromPath(iconPath);
}
return url;
} }
onUpdateNotAvailable = () => { onUpdateNotAvailable = () => {
@ -174,7 +172,7 @@ export default class AutoUpdateManager extends EventEmitter {
dialog.showMessageBox({ dialog.showMessageBox({
type: 'info', type: 'info',
buttons: [localized('OK')], buttons: [localized('OK')],
icon: NativeImage.createFromPath(this.iconURL()), icon: this.dialogIcon(),
message: localized('No update available.'), message: localized('No update available.'),
title: localized('No update available.'), title: localized('No update available.'),
detail: localized(`You're running the latest version of Mailspring (%@).`, this.version), detail: localized(`You're running the latest version of Mailspring (%@).`, this.version),
@ -186,7 +184,7 @@ export default class AutoUpdateManager extends EventEmitter {
dialog.showMessageBox({ dialog.showMessageBox({
type: 'warning', type: 'warning',
buttons: [localized('OK')], buttons: [localized('OK')],
icon: NativeImage.createFromPath(this.iconURL()), icon: this.dialogIcon(),
message: localized('There was an error checking for updates.'), message: localized('There was an error checking for updates.'),
title: localized('Update Error'), title: localized('Update Error'),
detail: message, detail: message,