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.
|
|
|
|
*/
|
|
|
|
|
2017-05-23 17:16:31 +03:00
|
|
|
import React from 'react';
|
2019-08-30 12:27:51 +03:00
|
|
|
import createReactClass from 'create-react-class';
|
2017-12-26 04:03:18 +03:00
|
|
|
import PropTypes from 'prop-types';
|
2017-05-23 17:16:31 +03:00
|
|
|
import sdk from '../../../index';
|
|
|
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
2017-05-25 13:39:08 +03:00
|
|
|
import { _t } from '../../../languageHandler';
|
2019-12-13 05:31:52 +03:00
|
|
|
import AuthPage from "../../views/auth/AuthPage";
|
2015-11-30 21:11:04 +03:00
|
|
|
|
2019-08-30 12:27:51 +03:00
|
|
|
module.exports = createReactClass({
|
2015-11-30 21:11:04 +03:00
|
|
|
displayName: 'PostRegistration',
|
|
|
|
|
|
|
|
propTypes: {
|
2017-12-26 04:03:18 +03:00
|
|
|
onComplete: PropTypes.func.isRequired,
|
2015-11-30 21:11:04 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
avatarUrl: null,
|
|
|
|
errorString: null,
|
2017-10-11 19:56:17 +03:00
|
|
|
busy: false,
|
2015-11-30 21:11:04 +03:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
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).
|
2017-10-11 19:56:17 +03:00
|
|
|
const cli = MatrixClientPeg.get();
|
2015-11-30 21:11:04 +03:00
|
|
|
this.setState({busy: true});
|
2017-10-11 19:56:17 +03:00
|
|
|
const self = this;
|
2019-11-18 13:03:05 +03:00
|
|
|
cli.getProfileInfo(cli.credentials.userId).then(function(result) {
|
2015-11-30 21:11:04 +03:00
|
|
|
self.setState({
|
|
|
|
avatarUrl: MatrixClientPeg.get().mxcUrlToHttp(result.avatar_url),
|
2017-10-11 19:56:17 +03:00
|
|
|
busy: false,
|
2015-11-30 21:11:04 +03:00
|
|
|
});
|
|
|
|
}, function(error) {
|
|
|
|
self.setState({
|
2017-06-07 13:40:46 +03:00
|
|
|
errorString: _t("Failed to fetch avatar URL"),
|
2017-10-11 19:56:17 +03:00
|
|
|
busy: false,
|
2015-11-30 21:11:04 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2017-10-11 19:56:17 +03:00
|
|
|
const ChangeDisplayName = sdk.getComponent('settings.ChangeDisplayName');
|
|
|
|
const ChangeAvatar = sdk.getComponent('settings.ChangeAvatar');
|
2019-01-22 03:33:17 +03:00
|
|
|
const AuthHeader = sdk.getComponent('auth.AuthHeader');
|
2019-01-23 04:28:23 +03:00
|
|
|
const AuthBody = sdk.getComponent("auth.AuthBody");
|
2015-11-30 21:11:04 +03:00
|
|
|
return (
|
2019-01-22 03:33:17 +03:00
|
|
|
<AuthPage>
|
2019-01-22 03:49:28 +03:00
|
|
|
<AuthHeader />
|
2019-01-23 04:28:23 +03:00
|
|
|
<AuthBody>
|
|
|
|
<div className="mx_Login_profile">
|
|
|
|
{ _t('Set a display name:') }
|
|
|
|
<ChangeDisplayName />
|
|
|
|
{ _t('Upload an avatar:') }
|
|
|
|
<ChangeAvatar
|
|
|
|
initialAvatarUrl={this.state.avatarUrl} />
|
|
|
|
<button onClick={this.props.onComplete}>{ _t('Continue') }</button>
|
|
|
|
{ this.state.errorString }
|
|
|
|
</div>
|
|
|
|
</AuthBody>
|
2019-01-22 03:33:17 +03:00
|
|
|
</AuthPage>
|
2015-11-30 21:11:04 +03:00
|
|
|
);
|
2017-10-11 19:56:17 +03:00
|
|
|
},
|
2015-11-30 21:11:04 +03:00
|
|
|
});
|