2022-01-28 20:45:04 +00:00
|
|
|
const updater = require('./updater');
|
2021-12-09 16:25:14 +00:00
|
|
|
|
2022-01-28 20:45:04 +00:00
|
|
|
const buildInfo = require('../utils/buildInfo');
|
2022-02-03 21:53:59 +00:00
|
|
|
const Constants = require('../Constants');
|
2021-12-09 16:25:14 +00:00
|
|
|
|
2022-01-28 20:45:04 +00:00
|
|
|
const { fatal, handled } = require('../errorHandler');
|
2022-02-03 21:53:59 +00:00
|
|
|
const splash = require('../splash');
|
2021-12-09 16:25:14 +00:00
|
|
|
|
|
|
|
|
2022-01-28 20:45:04 +00:00
|
|
|
exports.update = (startMin, done, show) => {
|
2022-02-03 21:53:59 +00:00
|
|
|
if (updater.tryInitUpdater(buildInfo, Constants.NEW_UPDATE_ENDPOINT)) {
|
2022-01-28 21:02:49 +00:00
|
|
|
const inst = updater.getUpdater();
|
2021-12-09 16:25:14 +00:00
|
|
|
|
2022-02-16 15:48:29 +00:00
|
|
|
inst.on('host-updated', () => require('../autoStart').update(() => {}));
|
2022-01-28 21:02:49 +00:00
|
|
|
inst.on('unhandled-exception', fatal);
|
2022-03-10 22:23:33 +00:00
|
|
|
inst.on('InconsistentInstallerState', fatal);
|
2022-01-28 21:02:49 +00:00
|
|
|
inst.on('update-error', handled);
|
2021-12-09 16:25:14 +00:00
|
|
|
|
2022-02-16 15:48:29 +00:00
|
|
|
require('../firstRun').performFirstRunTasks(inst);
|
2021-12-09 16:25:14 +00:00
|
|
|
} else {
|
2022-02-16 15:48:29 +00:00
|
|
|
require('./moduleUpdater').init(Constants.UPDATE_ENDPOINT, require('../appSettings').getSettings(), buildInfo);
|
2021-12-09 16:25:14 +00:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:53:59 +00:00
|
|
|
splash.initSplash(startMin);
|
2022-03-13 15:53:33 +00:00
|
|
|
splash.events.once('APP_SHOULD_LAUNCH', done);
|
|
|
|
splash.events.once('APP_SHOULD_SHOW', show);
|
2022-01-28 20:45:04 +00:00
|
|
|
};
|
2021-12-09 16:25:14 +00:00
|
|
|
|
2022-02-03 21:53:59 +00:00
|
|
|
exports.focusSplash = () => splash.focusWindow();
|