Mati Dastugue c57885d489
Desktop app (#745)
* Set up electron app

* Update dependencies

* Update package.json

* Added https support

* Add support for Ledger

* Updated certs

* Added auto updates messages

* Update auto-updater method

* Update package.json

* Added build resources

* Update preload

* Update Ledger method on mac

* Update build

* Merge with develop

* Added support for Portis

* Fix electron error and updater

* Update auto updater

* Fix dependencies

* Merge with develop

* Change auto update functionality

* Edit package.json and added github actions

* Updated github actions

* Fixed Torus + Update github actions

* Updated release.yml

* Try only ubuntu

* Update package.json

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* Updated safe-contracts

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* v1.9.6

* Updated deploy branch

* Updated script

Co-authored-by: Mati Dastugue <matias.dastugue@mercadolibre.com>
2020-04-24 18:10:37 +04:00

70 lines
2.0 KiB
JavaScript

const os = require('os');
const fetch = require('node-fetch');
const { dialog, app } = require('electron');
const log = require('electron-log');
const isDev = require("electron-is-dev");
const { autoUpdater } = require("electron-updater");
// This logging setup is not required for auto-updates to work,
// but it sure makes debugging easier :)
//-------------------------------------------------------------------
autoUpdater.autoDownload = false
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
log.info('App starting...');
let initialized = false;
let downloadProgress = 0;
function init(mainWindow) {
if(initialized || isDev) return;
initialized = true;
autoUpdater.on('error', (error) => {
dialog.showErrorBox('Error: ', error == null ? "unknown" : (error.stack || error).toString());
});
autoUpdater.on('update-available', () => {
dialog.showMessageBox({
type: 'info',
title: 'Found Updates',
message: 'There is a newer version of this app available. Do you want to update now?',
buttons: ['Yes', 'Remind me later'],
cancelId:1,
}).then(result => {
if(result.response === 0){
autoUpdater.downloadUpdate();
}
});
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
autoUpdater.logger.info("Update Downloaded...");
dialog.showMessageBox({
title: 'Install Updates',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new version has been downloaded. Restart the application to apply the updates.',
buttons: ['Restart', 'Cancel'],
cancelId:1,
}).then(result => {
if(result.response === 0){
autoUpdater.quitAndInstall();
}
});
});
});
autoUpdater.on("download-progress", (d) => {
downloadProgress = d.percent;
autoUpdater.logger.info(downloadProgress);
});
autoUpdater.checkForUpdates();
}
module.exports = {
init,
};