From d44adcb7a9c239a457fa0f0bfb094012b123ab63 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 8 Nov 2016 10:45:19 +0000 Subject: [PATCH 1/3] Fix the vector web version in UserSettings Add a getAppVersion() function to the platform rather than relying on the updater code firing an event before we know what the app version is. --- src/BasePlatform.js | 8 ++++++++ src/components/structures/LoggedInView.js | 1 - src/components/structures/UserSettings.js | 14 +++++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/BasePlatform.js b/src/BasePlatform.js index ff8fecf913..ffb32fce64 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -65,4 +65,12 @@ export default class BasePlatform { displayNotification(title: string, msg: string, avatarUrl: string) { } + + /** + * Returns a promise that resolves to a string representing + * the current version of the application. + */ + getAppVersion() { + return q(); + } } diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index e006f6ee3f..7c0fe14edd 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -167,7 +167,6 @@ export default React.createClass({ case PageTypes.UserSettings: page_element = { + this.setState({ + vectorVersion: appVersion, + }); + }, (e) => { + console.log("Failed to fetch app version", e); + }); + } + dis.dispatch({ action: 'ui_opacity', sideOpacity: 0.3, @@ -587,7 +599,7 @@ module.exports = React.createClass({
matrix-react-sdk version: {REACT_SDK_VERSION}
- vector-web version: {this.props.version}
+ vector-web version: {this.state.vectorVersion !== null ? this.state.vectorVersion : 'unknown'}
olm version: {olmVersionString}
From d871ca2b243e910e1aced3e90c6a0518ab76b76c Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 8 Nov 2016 11:43:24 +0000 Subject: [PATCH 2/3] PR feedback --- src/BasePlatform.js | 2 +- src/components/structures/UserSettings.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/BasePlatform.js b/src/BasePlatform.js index ffb32fce64..897a1a2dc8 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -71,6 +71,6 @@ export default class BasePlatform { * the current version of the application. */ getAppVersion() { - return q(); + throw new Error("getAppVersion not implemented!"); } } diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index b69793c539..c139999748 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -36,7 +36,6 @@ module.exports = React.createClass({ displayName: 'UserSettings', propTypes: { - version: React.PropTypes.string, onClose: React.PropTypes.func, // The brand string given when creating email pushers brand: React.PropTypes.string, @@ -66,8 +65,11 @@ module.exports = React.createClass({ }, componentWillMount: function() { + this._unmounted = false; + if (PlatformPeg.get()) { PlatformPeg.get().getAppVersion().done((appVersion) => { + if (this._unmounted) return; this.setState({ vectorVersion: appVersion, }); @@ -90,6 +92,7 @@ module.exports = React.createClass({ }, componentWillUnmount: function() { + this._unmounted = true; dis.dispatch({ action: 'ui_opacity', sideOpacity: 1.0, From 857c0d174742e43547a6ae585f0c0c5988598d84 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 11 Nov 2016 10:05:53 +0000 Subject: [PATCH 3/3] Wrap getAppVersion() in promise in case it throws --- src/components/structures/UserSettings.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index c139999748..c6efc55607 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -68,7 +68,9 @@ module.exports = React.createClass({ this._unmounted = false; if (PlatformPeg.get()) { - PlatformPeg.get().getAppVersion().done((appVersion) => { + q().then(() => { + return PlatformPeg.get().getAppVersion(); + }).done((appVersion) => { if (this._unmounted) return; this.setState({ vectorVersion: appVersion,