diff --git a/main.js b/main.js
index c08874290270..70e6efc0f839 100644
--- a/main.js
+++ b/main.js
@@ -458,7 +458,33 @@ async function startApp() {
workerWindow.on('closed', () => {
session.defaultSession.flushStorageData();
- session.defaultSession.cookies.flushStore().then(() => app.quit());
+ session.defaultSession.cookies.flushStore().then(() => {
+ // Run updater if update available
+ if (
+ !process.argv.includes('--skip-update') &&
+ (process.env.NODE_ENV === 'production' || process.env.SLOBS_FORCE_AUTO_UPDATE)
+ ) {
+ // Windows uses our custom update, Mac uses electron-updater
+ if (process.platform === 'win32') {
+ const updateInfo = {
+ baseUrl: 'https://slobs-cdn.streamlabs.com',
+ version: pjson.version,
+ exec: process.argv,
+ cwd: process.cwd(),
+ waitPids: [process.pid],
+ appDir: path.dirname(app.getPath('exe')),
+ tempDir: path.join(app.getPath('temp'), 'slobs-updater'),
+ cacheDir: app.getPath('userData'),
+ versionFileName: `${releaseChannel}.json`,
+ };
+ bootstrap(updateInfo, startApp, app.exit);
+ } else {
+ new Updater(startApp, releaseChannel).run();
+ }
+ } else {
+ app.quit();
+ }
+ });
});
// Pre-initialize the child window
@@ -620,31 +646,7 @@ ipcMain.on('protocolLinkReady', () => {
});
app.on('ready', () => {
- if (
- !process.argv.includes('--skip-update') &&
- (process.env.NODE_ENV === 'production' || process.env.SLOBS_FORCE_AUTO_UPDATE)
- ) {
- // Windows uses our custom update, Mac uses electron-updater
- if (process.platform === 'win32') {
- const updateInfo = {
- baseUrl: 'https://slobs-cdn.streamlabs.com',
- version: pjson.version,
- exec: process.argv,
- cwd: process.cwd(),
- waitPids: [process.pid],
- appDir: path.dirname(app.getPath('exe')),
- tempDir: path.join(app.getPath('temp'), 'slobs-updater'),
- cacheDir: app.getPath('userData'),
- versionFileName: `${releaseChannel}.json`,
- };
-
- bootstrap(updateInfo, startApp, app.exit);
- } else {
- new Updater(startApp, releaseChannel).run();
- }
- } else {
- startApp();
- }
+ startApp();
});
ipcMain.on('openDevTools', () => {
diff --git a/updater/UpdaterWindow.vue b/updater/UpdaterWindow.vue
deleted file mode 100644
index 3153d96cbdd1..000000000000
--- a/updater/UpdaterWindow.vue
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
- {{ message }}
-
-
- {{ subMessage }}
-
-
-
-
-
-
-
diff --git a/updater/index.html b/updater/index.html
deleted file mode 100644
index 4086118f2f25..000000000000
--- a/updater/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/updater/mac/Updater.js b/updater/mac/Updater.js
index 56363bb880a5..297deb898742 100644
--- a/updater/mac/Updater.js
+++ b/updater/mac/Updater.js
@@ -2,6 +2,7 @@
// be required by the main electron process.
const { autoUpdater } = require('electron-updater');
+const path = require('path');
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
class Updater {
@@ -13,6 +14,7 @@ class Updater {
// good option either, since then closing the auto updater will
// orphan the main process in the background.
constructor(startApp, channel) {
+ autoUpdater.autoDownload = false;
this.startApp = startApp;
if (process.arch === 'arm64') {
this.channel = 'arm64-' + channel;
@@ -57,6 +59,13 @@ class Updater {
this.browserWindow = this.initWindow();
this.updateState.version = info.version;
this.updateState.percent = 0;
+ this.updateState.updating = false;
+
+ if (info.releaseNotes === 'force-update') {
+ autoUpdater.downloadUpdate();
+ this.updateState.updating = true;
+ }
+
this.pushState();
});
@@ -94,6 +103,19 @@ class Updater {
ipcMain.on('autoUpdate-getState', () => {
this.pushState();
});
+
+ ipcMain.on('autoUpdate-postpone', () => {
+ console.log('Updater: Update postponed');
+ this.startApp();
+ this.finished = true;
+ if (this.browserWindow) this.browserWindow.close();
+ });
+
+ ipcMain.on('autoUpdate-confirm', () => {
+ console.log('Updater: Update beginning');
+ this.updateState.updating = true;
+ autoUpdater.downloadUpdate();
+ });
}
initWindow() {
@@ -116,7 +138,7 @@ class Updater {
if (!this.finished) app.quit();
});
- browserWindow.loadURL('file://' + __dirname + '/index.html');
+ browserWindow.loadURL(path.join('file://', __dirname, '/index.html'));
return browserWindow;
}
diff --git a/updater/mac/UpdaterWindow.vue b/updater/mac/UpdaterWindow.vue
index 97558ce010f9..c4701470e2fa 100644
--- a/updater/mac/UpdaterWindow.vue
+++ b/updater/mac/UpdaterWindow.vue
@@ -5,6 +5,11 @@
{{ message }}
+
+
+
+
+
{{ percentComplete }}% complete
@@ -37,6 +42,12 @@ export default {
},
mounted() {
ipcRenderer.on('autoUpdate-pushState', (event, data) => {
+ // New update available, return early to allow user agency
+ if (data.updating === false) {
+ this.message = `New version ${data.version} available. Update now?`;
+ return;
+ }
+ // Accepted download
if (data.version) {
this.message = `Downloading version ${data.version}`;
}
@@ -59,6 +70,12 @@ export default {
remote.shell.openExternal('https://streamlabs.com/streamlabs-obs');
remote.app.quit();
},
+ confirmUpdate() {
+ ipcRenderer.send('autoUpdate-confirm');
+ },
+ postponeUpdate() {
+ ipcRenderer.send('autoUpdate-postpone');
+ },
},
};
@@ -110,4 +127,24 @@ export default {
color: #eee;
}
}
+.UpdaterWindow-actions {
+ display: flex;
+ width: 100%;
+ justify-content: space-around;
+ button {
+ border: 1px solid transparent;
+ margin: 0;
+ font-family: 'Roboto', sans-serif;
+ min-height: 32px;
+ line-height: 30px;
+ cursor: pointer;
+ background-color: #4f5e65;
+ padding-left: 8px;
+ padding-right: 8px;
+ &:hover {
+ color: #fff;
+ background-color: lighten(#4f5e65, 8%);
+ }
+ }
+}
diff --git a/updater/ui.js b/updater/ui.js
deleted file mode 100644
index be95e3997383..000000000000
--- a/updater/ui.js
+++ /dev/null
@@ -1,15 +0,0 @@
-// This is the entry point into the updater app
-
-import Vue from 'vue';
-import UpdaterWindow from './UpdaterWindow.vue';
-
-document.addEventListener('DOMContentLoaded', () => {
-
- new Vue({
- el: '#app',
- render: createEl => {
- return createEl(UpdaterWindow);
- }
- });
-
-});