mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-13 11:38:31 +08:00
feat(channels): Choose an update channel! Limited time only!
Summary: Just a small select input. Test Plan: Run tests Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D3282
This commit is contained in:
parent
ebb8d02c3d
commit
35c3a66642
3 changed files with 108 additions and 3 deletions
|
@ -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}
|
||||
/>
|
||||
|
||||
<UpdateChannelSection />
|
||||
|
||||
<div className="local-data">
|
||||
<h6>Local Data</h6>
|
||||
<div className="btn" onClick={this._resetEmailCache}>Reset Email Cache</div>
|
||||
|
|
|
@ -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 (
|
||||
<section>
|
||||
<h6>Updates</h6>
|
||||
<label forHtml="">Release channel: </label>
|
||||
<select
|
||||
style={{minWidth: 130}}
|
||||
value={current.name}
|
||||
onChange={this._onSelectedChannel}
|
||||
disabled={saving}
|
||||
>
|
||||
{
|
||||
available.map((channel) => {
|
||||
return (<option value={channel.name}>
|
||||
{channel.name[0].toUpperCase() + channel.name.substr(1)}
|
||||
</option>);
|
||||
})
|
||||
}
|
||||
</select>
|
||||
<p>
|
||||
Subscribe to different update channels to receive previews of new features.
|
||||
Note that some update channels may be less stable!
|
||||
</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default UpdateChannelSection;
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue