Move 'new version' support into Platform

Also adds support for the platform providing a changelog
pull/21833/head
David Baker 2016-11-02 15:58:17 +00:00
parent f433f9ca32
commit 3c4370c180
2 changed files with 31 additions and 3 deletions

View File

@ -38,4 +38,21 @@ export default class BasePlatform {
displayNotification(title: string, msg: string, avatarUrl: string) { displayNotification(title: string, msg: string, avatarUrl: string) {
} }
/**
* Check for the availability of an update to the version of the
* app that's currently running.
* If an update is available, this function should dispatch the
* 'new_version' action.
*/
pollForUpdate() {
}
/**
* Update the currently running app to the latest available
* version and replace this instance of the app with the
* new version.
*/
installUpdate() {
}
} }

View File

@ -105,6 +105,8 @@ module.exports = React.createClass({
version: null, version: null,
newVersion: null, newVersion: null,
hasNewVersion: false,
newVersionReleaseNotes: null,
// The username to default to when upgrading an account from a guest // The username to default to when upgrading an account from a guest
upgradeUsername: null, upgradeUsername: null,
@ -469,6 +471,12 @@ module.exports = React.createClass({
case 'load_completed': case 'load_completed':
this._onLoadCompleted(); this._onLoadCompleted();
break; break;
case 'new_version':
this.onVersion(
payload.currentVersion, payload.newVersion,
payload.releaseNotes
);
break;
} }
}, },
@ -961,11 +969,12 @@ module.exports = React.createClass({
this.showScreen("settings"); this.showScreen("settings");
}, },
onVersion: function(current, latest) { onVersion: function(current, latest, releaseNotes) {
this.setState({ this.setState({
version: current, version: current,
newVersion: latest, newVersion: latest,
hasNewVersion: current !== latest hasNewVersion: current !== latest,
newVersionReleaseNotes: releaseNotes,
}); });
}, },
@ -1100,7 +1109,9 @@ module.exports = React.createClass({
var topBar; var topBar;
if (this.state.hasNewVersion) { if (this.state.hasNewVersion) {
topBar = <NewVersionBar version={this.state.version} newVersion={this.state.newVersion} />; topBar = <NewVersionBar version={this.state.version} newVersion={this.state.newVersion}
releaseNotes={this.state.newVersionReleaseNotes}
/>;
} }
else if (MatrixClientPeg.get().isGuest()) { else if (MatrixClientPeg.get().isGuest()) {
topBar = <GuestWarningBar />; topBar = <GuestWarningBar />;