Merge pull request #542 from matrix-org/dbkr/get_app_version

Fix the vector web version in UserSettings
This commit is contained in:
Richard van der Hoff 2016-11-11 11:11:36 +00:00 committed by GitHub
commit 998690431f
3 changed files with 27 additions and 3 deletions

View file

@ -65,4 +65,12 @@ export default class BasePlatform {
displayNotification(title: string, msg: string, avatarUrl: string) { displayNotification(title: string, msg: string, avatarUrl: string) {
} }
/**
* Returns a promise that resolves to a string representing
* the current version of the application.
*/
getAppVersion() {
throw new Error("getAppVersion not implemented!");
}
} }

View file

@ -167,7 +167,6 @@ export default React.createClass({
case PageTypes.UserSettings: case PageTypes.UserSettings:
page_element = <UserSettings page_element = <UserSettings
onClose={this.props.onUserSettingsClose} onClose={this.props.onUserSettingsClose}
version={this.props.version}
brand={this.props.config.brand} brand={this.props.config.brand}
collapsedRhs={this.props.collapse_rhs} collapsedRhs={this.props.collapse_rhs}
enableLabs={this.props.config.enableLabs} enableLabs={this.props.config.enableLabs}

View file

@ -17,6 +17,7 @@ var React = require('react');
var ReactDOM = require('react-dom'); var ReactDOM = require('react-dom');
var sdk = require('../../index'); var sdk = require('../../index');
var MatrixClientPeg = require("../../MatrixClientPeg"); var MatrixClientPeg = require("../../MatrixClientPeg");
var PlatformPeg = require("../../PlatformPeg");
var Modal = require('../../Modal'); var Modal = require('../../Modal');
var dis = require("../../dispatcher"); var dis = require("../../dispatcher");
var q = require('q'); var q = require('q');
@ -35,7 +36,6 @@ module.exports = React.createClass({
displayName: 'UserSettings', displayName: 'UserSettings',
propTypes: { propTypes: {
version: React.PropTypes.string,
onClose: React.PropTypes.func, onClose: React.PropTypes.func,
// The brand string given when creating email pushers // The brand string given when creating email pushers
brand: React.PropTypes.string, brand: React.PropTypes.string,
@ -60,10 +60,26 @@ module.exports = React.createClass({
threePids: [], threePids: [],
phase: "UserSettings.LOADING", // LOADING, DISPLAY phase: "UserSettings.LOADING", // LOADING, DISPLAY
email_add_pending: false, email_add_pending: false,
vectorVersion: null,
}; };
}, },
componentWillMount: function() { componentWillMount: function() {
this._unmounted = false;
if (PlatformPeg.get()) {
q().then(() => {
return PlatformPeg.get().getAppVersion();
}).done((appVersion) => {
if (this._unmounted) return;
this.setState({
vectorVersion: appVersion,
});
}, (e) => {
console.log("Failed to fetch app version", e);
});
}
dis.dispatch({ dis.dispatch({
action: 'ui_opacity', action: 'ui_opacity',
sideOpacity: 0.3, sideOpacity: 0.3,
@ -78,6 +94,7 @@ module.exports = React.createClass({
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
this._unmounted = true;
dis.dispatch({ dis.dispatch({
action: 'ui_opacity', action: 'ui_opacity',
sideOpacity: 1.0, sideOpacity: 1.0,
@ -587,7 +604,7 @@ module.exports = React.createClass({
</div> </div>
<div className="mx_UserSettings_advanced"> <div className="mx_UserSettings_advanced">
matrix-react-sdk version: {REACT_SDK_VERSION}<br/> matrix-react-sdk version: {REACT_SDK_VERSION}<br/>
vector-web version: {this.props.version}<br/> vector-web version: {this.state.vectorVersion !== null ? this.state.vectorVersion : 'unknown'}<br/>
olm version: {olmVersionString}<br/> olm version: {olmVersionString}<br/>
</div> </div>
</div> </div>