2015-11-30 21:11:04 +03:00
|
|
|
/*
|
2016-01-07 07:06:39 +03:00
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
2015-11-30 21:11:04 +03:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2017-05-23 17:16:31 +03:00
|
|
|
import React from 'react';
|
|
|
|
import sdk from '../../../index';
|
|
|
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
2017-05-25 13:39:08 +03:00
|
|
|
import { _t } from '../../../languageHandler';
|
2015-11-30 21:11:04 +03:00
|
|
|
|
|
|
|
module.exports = React.createClass({
|
|
|
|
displayName: 'PostRegistration',
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
onComplete: React.PropTypes.func.isRequired
|
|
|
|
},
|
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
avatarUrl: null,
|
|
|
|
errorString: null,
|
|
|
|
busy: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillMount: function() {
|
|
|
|
// There is some assymetry between ChangeDisplayName and ChangeAvatar,
|
|
|
|
// as ChangeDisplayName will auto-get the name but ChangeAvatar expects
|
|
|
|
// the URL to be passed to you (because it's also used for room avatars).
|
|
|
|
var cli = MatrixClientPeg.get();
|
|
|
|
this.setState({busy: true});
|
|
|
|
var self = this;
|
|
|
|
cli.getProfileInfo(cli.credentials.userId).done(function(result) {
|
|
|
|
self.setState({
|
|
|
|
avatarUrl: MatrixClientPeg.get().mxcUrlToHttp(result.avatar_url),
|
|
|
|
busy: false
|
|
|
|
});
|
|
|
|
}, function(error) {
|
|
|
|
self.setState({
|
2017-06-07 13:40:46 +03:00
|
|
|
errorString: _t("Failed to fetch avatar URL"),
|
2015-11-30 21:11:04 +03:00
|
|
|
busy: false
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
var ChangeDisplayName = sdk.getComponent('settings.ChangeDisplayName');
|
|
|
|
var ChangeAvatar = sdk.getComponent('settings.ChangeAvatar');
|
2015-12-01 19:29:58 +03:00
|
|
|
var LoginHeader = sdk.getComponent('login.LoginHeader');
|
2015-11-30 21:11:04 +03:00
|
|
|
return (
|
|
|
|
<div className="mx_Login">
|
|
|
|
<div className="mx_Login_box">
|
2015-12-01 19:29:58 +03:00
|
|
|
<LoginHeader />
|
2015-11-30 21:11:04 +03:00
|
|
|
<div className="mx_Login_profile">
|
2017-05-23 17:16:31 +03:00
|
|
|
{ _t('Set a display name:') }
|
2015-11-30 21:11:04 +03:00
|
|
|
<ChangeDisplayName />
|
2017-05-23 17:16:31 +03:00
|
|
|
{ _t('Upload an avatar:') }
|
2015-11-30 21:11:04 +03:00
|
|
|
<ChangeAvatar
|
|
|
|
initialAvatarUrl={this.state.avatarUrl} />
|
2017-05-23 17:16:31 +03:00
|
|
|
<button onClick={this.props.onComplete}>{ _t('Continue') }</button>
|
2015-11-30 21:11:04 +03:00
|
|
|
{this.state.errorString}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|