mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-04 14:03:27 +00:00
Compare commits
4 Commits
v2.2.0-bet
...
auto-updat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ad74081c4 | ||
|
|
6163ad85e0 | ||
|
|
cfc97c9b73 | ||
|
|
2e70b515da |
@@ -1,11 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const { app, dialog } = require('electron');
|
const { app, dialog, shell } = require('electron');
|
||||||
const { autoUpdater } = require('electron-updater');
|
const { autoUpdater } = require('electron-updater');
|
||||||
const isDev = require('electron-is-dev');
|
const isDev = require('electron-is-dev');
|
||||||
|
|
||||||
const ConfigUtil = require('./../renderer/js/utils/config-util.js');
|
const ConfigUtil = require('./../renderer/js/utils/config-util.js');
|
||||||
|
|
||||||
function appUpdater() {
|
function appUpdater(updateFromMenu = false) {
|
||||||
// Don't initiate auto-updates in development
|
// Don't initiate auto-updates in development
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
return;
|
return;
|
||||||
@@ -17,6 +17,8 @@ function appUpdater() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let updateAvailable = false;
|
||||||
|
|
||||||
// Create Logs directory
|
// Create Logs directory
|
||||||
const LogsDir = `${app.getPath('userData')}/Logs`;
|
const LogsDir = `${app.getPath('userData')}/Logs`;
|
||||||
|
|
||||||
@@ -28,7 +30,58 @@ function appUpdater() {
|
|||||||
autoUpdater.logger = log;
|
autoUpdater.logger = log;
|
||||||
|
|
||||||
// Handle auto updates for beta/pre releases
|
// Handle auto updates for beta/pre releases
|
||||||
autoUpdater.allowPrerelease = ConfigUtil.getConfigItem('betaUpdate') || false;
|
const isBetaUpdate = ConfigUtil.getConfigItem('betaUpdate');
|
||||||
|
|
||||||
|
autoUpdater.allowPrerelease = isBetaUpdate || false;
|
||||||
|
|
||||||
|
const eventsListenerRemove = ['update-available', 'update-not-available'];
|
||||||
|
autoUpdater.on('update-available', info => {
|
||||||
|
if (updateFromMenu) {
|
||||||
|
dialog.showMessageBox({
|
||||||
|
message: `A new version ${info.version}, of Zulip Desktop is available`,
|
||||||
|
detail: 'The update will be downloaded in the background. You will be notified when it is ready to be installed.'
|
||||||
|
});
|
||||||
|
|
||||||
|
updateAvailable = true;
|
||||||
|
|
||||||
|
// This is to prevent removal of 'update-downloaded' and 'error' event listener.
|
||||||
|
eventsListenerRemove.forEach(event => {
|
||||||
|
autoUpdater.removeAllListeners(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
autoUpdater.on('update-not-available', () => {
|
||||||
|
if (updateFromMenu) {
|
||||||
|
dialog.showMessageBox({
|
||||||
|
message: 'No updates available',
|
||||||
|
detail: `You are running the latest version of Zulip Desktop.\nVersion: ${app.getVersion()}`
|
||||||
|
});
|
||||||
|
// Remove all autoUpdator listeners so that next time autoUpdator is manually called these
|
||||||
|
// listeners don't trigger multiple times.
|
||||||
|
autoUpdater.removeAllListeners();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
autoUpdater.on('error', error => {
|
||||||
|
if (updateFromMenu) {
|
||||||
|
const messageText = (updateAvailable) ? ('Unable to download the updates') : ('Unable to check for updates');
|
||||||
|
dialog.showMessageBox({
|
||||||
|
type: 'error',
|
||||||
|
buttons: ['Manual Download', 'Cancel'],
|
||||||
|
message: messageText,
|
||||||
|
detail: (error).toString() + `\n\nThe latest version of Zulip Desktop is available at -\nhttps://zulipchat.com/apps/.\n
|
||||||
|
Current Version: ${app.getVersion()}`
|
||||||
|
}, response => {
|
||||||
|
if (response === 0) {
|
||||||
|
shell.openExternal('https://zulipchat.com/apps/');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Remove all autoUpdator listeners so that next time autoUpdator is manually called these
|
||||||
|
// listeners don't trigger multiple times.
|
||||||
|
autoUpdater.removeAllListeners();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Ask the user if update is available
|
// Ask the user if update is available
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|||||||
@@ -161,7 +161,9 @@ app.on('ready', () => {
|
|||||||
|
|
||||||
page.once('did-frame-finish-load', () => {
|
page.once('did-frame-finish-load', () => {
|
||||||
// Initate auto-updates on MacOS and Windows
|
// Initate auto-updates on MacOS and Windows
|
||||||
|
if (ConfigUtil.getConfigItem('autoUpdate')) {
|
||||||
appUpdater();
|
appUpdater();
|
||||||
|
}
|
||||||
crashHandler();
|
crashHandler();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const path = require('path');
|
|||||||
const { app, shell, BrowserWindow, Menu, dialog } = require('electron');
|
const { app, shell, BrowserWindow, Menu, dialog } = require('electron');
|
||||||
|
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
const { appUpdater } = require('./autoupdater');
|
||||||
|
|
||||||
const ConfigUtil = require(__dirname + '/../renderer/js/utils/config-util.js');
|
const ConfigUtil = require(__dirname + '/../renderer/js/utils/config-util.js');
|
||||||
const DNDUtil = require(__dirname + '/../renderer/js/utils/dnd-util.js');
|
const DNDUtil = require(__dirname + '/../renderer/js/utils/dnd-util.js');
|
||||||
@@ -195,6 +196,11 @@ class AppMenu {
|
|||||||
AppMenu.sendAction('open-about');
|
AppMenu.sendAction('open-about');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
label: `Check for Update`,
|
||||||
|
click() {
|
||||||
|
AppMenu.checkForUpdate();
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
}, {
|
}, {
|
||||||
@@ -302,6 +308,11 @@ class AppMenu {
|
|||||||
AppMenu.sendAction('open-about');
|
AppMenu.sendAction('open-about');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
label: `Check for Update`,
|
||||||
|
click() {
|
||||||
|
AppMenu.checkForUpdate();
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
}, {
|
}, {
|
||||||
@@ -399,6 +410,9 @@ class AppMenu {
|
|||||||
win.webContents.send(action, ...params);
|
win.webContents.send(action, ...params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static checkForUpdate() {
|
||||||
|
appUpdater(true);
|
||||||
|
}
|
||||||
static resetAppSettings() {
|
static resetAppSettings() {
|
||||||
const resetAppSettingsMessage = 'By proceeding you will be removing all connected organizations and preferences from Zulip.';
|
const resetAppSettingsMessage = 'By proceeding you will be removing all connected organizations and preferences from Zulip.';
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ class ServerManagerView {
|
|||||||
startMinimized: false,
|
startMinimized: false,
|
||||||
enableSpellchecker: true,
|
enableSpellchecker: true,
|
||||||
showNotification: true,
|
showNotification: true,
|
||||||
|
autoUpdate: true,
|
||||||
betaUpdate: false,
|
betaUpdate: false,
|
||||||
silent: false,
|
silent: false,
|
||||||
lastActiveTab: 0,
|
lastActiveTab: 0,
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ class GeneralSection extends BaseSection {
|
|||||||
</div>
|
</div>
|
||||||
<div class="title">App Updates</div>
|
<div class="title">App Updates</div>
|
||||||
<div class="settings-card">
|
<div class="settings-card">
|
||||||
|
<div class="setting-row" id="autoupdate-option">
|
||||||
|
<div class="setting-description">Enable auto updates</div>
|
||||||
|
<div class="setting-control"></div>
|
||||||
|
</div>
|
||||||
<div class="setting-row" id="betaupdate-option">
|
<div class="setting-row" id="betaupdate-option">
|
||||||
<div class="setting-description">Get beta updates</div>
|
<div class="setting-description">Get beta updates</div>
|
||||||
<div class="setting-control"></div>
|
<div class="setting-control"></div>
|
||||||
@@ -104,7 +108,8 @@ class GeneralSection extends BaseSection {
|
|||||||
this.updateTrayOption();
|
this.updateTrayOption();
|
||||||
this.updateBadgeOption();
|
this.updateBadgeOption();
|
||||||
this.updateSilentOption();
|
this.updateSilentOption();
|
||||||
this.updateUpdateOption();
|
this.autoUpdateOption();
|
||||||
|
this.betaUpdateOption();
|
||||||
this.updateSidebarOption();
|
this.updateSidebarOption();
|
||||||
this.updateStartAtLoginOption();
|
this.updateStartAtLoginOption();
|
||||||
this.updateResetDataOption();
|
this.updateResetDataOption();
|
||||||
@@ -160,14 +165,26 @@ class GeneralSection extends BaseSection {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUpdateOption() {
|
autoUpdateOption() {
|
||||||
|
this.generateSettingOption({
|
||||||
|
$element: document.querySelector('#autoupdate-option .setting-control'),
|
||||||
|
value: ConfigUtil.getConfigItem('autoUpdate', true),
|
||||||
|
clickHandler: () => {
|
||||||
|
const newValue = !ConfigUtil.getConfigItem('autoUpdate');
|
||||||
|
ConfigUtil.setConfigItem('autoUpdate', newValue);
|
||||||
|
this.autoUpdateOption();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
betaUpdateOption() {
|
||||||
this.generateSettingOption({
|
this.generateSettingOption({
|
||||||
$element: document.querySelector('#betaupdate-option .setting-control'),
|
$element: document.querySelector('#betaupdate-option .setting-control'),
|
||||||
value: ConfigUtil.getConfigItem('betaUpdate', false),
|
value: ConfigUtil.getConfigItem('betaUpdate', false),
|
||||||
clickHandler: () => {
|
clickHandler: () => {
|
||||||
const newValue = !ConfigUtil.getConfigItem('betaUpdate');
|
const newValue = !ConfigUtil.getConfigItem('betaUpdate');
|
||||||
ConfigUtil.setConfigItem('betaUpdate', newValue);
|
ConfigUtil.setConfigItem('betaUpdate', newValue);
|
||||||
this.updateUpdateOption();
|
this.betaUpdateOption();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@
|
|||||||
"cp-file": "^5.0.0",
|
"cp-file": "^5.0.0",
|
||||||
"devtron": "1.4.0",
|
"devtron": "1.4.0",
|
||||||
"electron": "2.0.0",
|
"electron": "2.0.0",
|
||||||
"electron-builder": "20.11.1",
|
"electron-builder": "20.13.4",
|
||||||
"electron-connect": "0.6.2",
|
"electron-connect": "0.6.2",
|
||||||
"electron-debug": "1.4.0",
|
"electron-debug": "1.4.0",
|
||||||
"google-translate-api": "2.3.0",
|
"google-translate-api": "2.3.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user