From 3c4370c1805c5a364f8103f3e8402e468a1d59d3 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 2 Nov 2016 15:58:17 +0000 Subject: [PATCH 1/2] Move 'new version' support into Platform Also adds support for the platform providing a changelog --- src/BasePlatform.js | 17 +++++++++++++++++ src/components/structures/MatrixChat.js | 17 ++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/BasePlatform.js b/src/BasePlatform.js index 2b5e89942e..aed568552a 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -38,4 +38,21 @@ export default class BasePlatform { 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() { + } } diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 9b37871ba9..8582b85d12 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -105,6 +105,8 @@ module.exports = React.createClass({ version: null, newVersion: null, + hasNewVersion: false, + newVersionReleaseNotes: null, // The username to default to when upgrading an account from a guest upgradeUsername: null, @@ -469,6 +471,12 @@ module.exports = React.createClass({ case 'load_completed': this._onLoadCompleted(); break; + case 'new_version': + this.onVersion( + payload.currentVersion, payload.newVersion, + payload.releaseNotes + ); + break; } }, @@ -961,11 +969,12 @@ module.exports = React.createClass({ this.showScreen("settings"); }, - onVersion: function(current, latest) { + onVersion: function(current, latest, releaseNotes) { this.setState({ version: current, newVersion: latest, - hasNewVersion: current !== latest + hasNewVersion: current !== latest, + newVersionReleaseNotes: releaseNotes, }); }, @@ -1100,7 +1109,9 @@ module.exports = React.createClass({ var topBar; if (this.state.hasNewVersion) { - topBar = ; + topBar = ; } else if (MatrixClientPeg.get().isGuest()) { topBar = ; From bd3fa6a7c5e5d4783036143215284b7d5b3e8bf1 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 2 Nov 2016 17:44:57 +0000 Subject: [PATCH 2/2] Move version specific stuff to vector --- src/BasePlatform.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/BasePlatform.js b/src/BasePlatform.js index aed568552a..2b5e89942e 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -38,21 +38,4 @@ export default class BasePlatform { 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() { - } }