diff --git a/internal_packages/preferences/lib/tabs/preferences-general.jsx b/internal_packages/preferences/lib/tabs/preferences-general.jsx
index dc0ef7e87..d1e328451 100644
--- a/internal_packages/preferences/lib/tabs/preferences-general.jsx
+++ b/internal_packages/preferences/lib/tabs/preferences-general.jsx
@@ -5,6 +5,7 @@ import fs from 'fs';
import ConfigSchemaItem from './config-schema-item';
import WorkspaceSection from './workspace-section';
import SendingSection from './sending-section';
+import UpdateChannelSection from './update-channel-section';
class PreferencesGeneral extends React.Component {
@@ -80,6 +81,8 @@ class PreferencesGeneral extends React.Component {
config={this.props.config}
/>
+
+
Local Data
Reset Email Cache
diff --git a/internal_packages/preferences/lib/tabs/update-channel-section.jsx b/internal_packages/preferences/lib/tabs/update-channel-section.jsx
new file mode 100644
index 000000000..9d8cda528
--- /dev/null
+++ b/internal_packages/preferences/lib/tabs/update-channel-section.jsx
@@ -0,0 +1,89 @@
+import React from 'react';
+import {remote} from 'electron';
+import {EdgehillAPI} from 'nylas-exports';
+
+const autoUpdater = remote.getGlobal('application').autoUpdateManager;
+
+class UpdateChannelSection extends React.Component {
+
+ static displayName = 'UpdateChannelSection';
+
+ constructor(props) {
+ super(props);
+ this.state = {
+ current: {name: 'Loading...'},
+ available: [{name: 'Loading...'}],
+ }
+ }
+
+ componentDidMount() {
+ this._refreshChannel();
+ this._mounted = true;
+ }
+
+ componentWillUnmount() {
+ this._mounted = false;
+ }
+
+ _refreshChannel() {
+ EdgehillAPI.makeRequest({
+ method: 'GET',
+ path: `/update-channel`,
+ qs: autoUpdater.parameters(),
+ json: true,
+ }).then(({current, available}) => {
+ if (!this._mounted) { return; }
+ this.setState({current, available});
+ });
+ }
+
+ _onSelectedChannel = (event) => {
+ const channel = event.target.value;
+
+ this.setState({saving: true});
+
+ EdgehillAPI.makeRequest({
+ method: 'POST',
+ path: `/update-channel`,
+ qs: Object.assign({channel}, autoUpdater.parameters()),
+ json: true,
+ }).then(({current, available}) => {
+ this.setState({current, available, saving: false});
+ }).catch((err) => {
+ this.setState({saving: false});
+ NylasEnv.showErrorDialog(err.toString())
+ });
+ }
+
+ render() {
+ const {current, available, saving} = this.state;
+
+ return (
+
+ Updates
+
+
+
+ Subscribe to different update channels to receive previews of new features.
+ Note that some update channels may be less stable!
+
+
+ );
+ }
+
+}
+
+export default UpdateChannelSection;
diff --git a/src/browser/auto-update-manager.es6 b/src/browser/auto-update-manager.es6
index 3dd80932a..7ed06b130 100644
--- a/src/browser/auto-update-manager.es6
+++ b/src/browser/auto-update-manager.es6
@@ -3,6 +3,7 @@ import {dialog} from 'electron';
import {EventEmitter} from 'events';
import path from 'path';
import fs from 'fs';
+import qs from 'querystring';
let autoUpdater = null;
@@ -38,7 +39,7 @@ export default class AutoUpdateManager extends EventEmitter {
process.nextTick(() => this.setupAutoUpdater());
}
- _updateFeedURL = () => {
+ parameters = () => {
let updaterId = this.config.get("nylas.identity.id");
if (!updaterId) {
updaterId = "anonymous";
@@ -53,12 +54,24 @@ export default class AutoUpdateManager extends EventEmitter {
}
const updaterEmails = emails.join(',');
+ return {
+ platform: process.platform,
+ arch: process.arch,
+ version: this.version,
+ id: updaterId,
+ emails: updaterEmails,
+ };
+ }
+
+ _updateFeedURL = () => {
+ const params = this.parameters();
+
if (process.platform === 'win32') {
// Squirrel for Windows can't handle query params
// https://github.com/Squirrel/Squirrel.Windows/issues/132
- this.feedURL = `https://edgehill.nylas.com/update-check/win32/${process.arch}/${this.version}/${updaterId}/${updaterEmails}`
+ this.feedURL = `https://edgehill.nylas.com/update-check/win32/${params.arch}/${params.version}/${params.id}/${params.emails}`
} else {
- this.feedURL = `https://edgehill.nylas.com/update-check?platform=${process.platform}&arch=${process.arch}&version=${this.version}&id=${updaterId}&emails=${updaterEmails}`;
+ this.feedURL = `https://edgehill.nylas.com/update-check?${qs.stringify(params)}`;
}
if (autoUpdater) {