diff --git a/src/controllers/templates/Register.js b/src/controllers/templates/Register.js new file mode 100644 index 0000000000..5f88d59059 --- /dev/null +++ b/src/controllers/templates/Register.js @@ -0,0 +1,58 @@ +/* +Copyright 2015 OpenMarket Ltd + +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'; + +var extend = require('matrix-react-sdk/lib/extend'); +var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); +var BaseRegisterController = require('matrix-react-sdk/lib/controllers/templates/Register.js'); + +var RegisterController = {}; +extend(RegisterController, BaseRegisterController); + +RegisterController.onRegistered = function(user_id, access_token) { + MatrixClientPeg.replaceUsingAccessToken( + this.state.hs_url, this.state.is_url, user_id, access_token + ); + + this.setState({ + step: 'profile', + busy: true + }); + + var self = this; + var cli = MatrixClientPeg.get(); + cli.getProfileInfo(cli.credentials.userId).done(function(result) { + self.setState({ + avatarUrl: result.avatar_url, + busy: false + }); + }, + function(err) { + console.err(err); + self.setState({ + busy: false + }); + }); +}; + +RegisterController.onAccountReady = function() { + if (this.props.onLoggedIn) { + this.props.onLoggedIn(); + } +}; + +module.exports = RegisterController; diff --git a/src/skins/vector/views/molecules/ChangeAvatar.js b/src/skins/vector/views/molecules/ChangeAvatar.js index 8fafacc863..52a59e3f8b 100644 --- a/src/skins/vector/views/molecules/ChangeAvatar.js +++ b/src/skins/vector/views/molecules/ChangeAvatar.js @@ -51,9 +51,6 @@ module.exports = React.createClass({ {this.state.errorText} -
- -
); case this.Phases.Uploading: diff --git a/src/skins/vector/views/organisms/UserSettings.js b/src/skins/vector/views/organisms/UserSettings.js index 44798aee50..6071f82edf 100644 --- a/src/skins/vector/views/organisms/UserSettings.js +++ b/src/skins/vector/views/organisms/UserSettings.js @@ -30,7 +30,15 @@ module.exports = React.createClass({ editAvatar: function() { var url = MatrixClientPeg.get().mxcUrlToHttp(this.state.avatarUrl); var ChangeAvatar = sdk.getComponent('molecules.ChangeAvatar'); - Modal.createDialog(ChangeAvatar, {initialAvatarUrl: url}); + var avatarDialog = ( +
+ +
+ +
+
+ ); + this.avatarDialog = Modal.createDialogWithElement(avatarDialog); }, addEmail: function() { @@ -55,6 +63,10 @@ module.exports = React.createClass({ this.logoutModal.closeDialog(); }, + onAvatarDialogCancel: function() { + this.avatarDialog.close(); + }, + render: function() { switch (this.state.phase) { case this.Phases.Loading: @@ -80,7 +92,7 @@ module.exports = React.createClass({
{this.state.threepids.map(function(val) { - return
{val.address}
; + return
{val.address}
; })}
diff --git a/src/skins/vector/views/templates/Register.js b/src/skins/vector/views/templates/Register.js index fa4a3e18d1..638dac1515 100644 --- a/src/skins/vector/views/templates/Register.js +++ b/src/skins/vector/views/templates/Register.js @@ -19,10 +19,11 @@ limitations under the License. var React = require('react'); var sdk = require('matrix-react-sdk') +var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg') var Loader = require("react-loader"); -var RegisterController = require('matrix-react-sdk/lib/controllers/templates/Register') +var RegisterController = require('../../../../controllers/templates/Register') module.exports = React.createClass({ DEFAULT_HS_URL: 'https://matrix.org', @@ -79,6 +80,10 @@ module.exports = React.createClass({ this.forceUpdate(); }, + onProfileContinueClicked: function() { + this.onAccountReady(); + }, + componentForStep: function(step) { switch (step) { case 'initial': @@ -127,6 +132,18 @@ module.exports = React.createClass({ return ( ); + } else if (this.state.step == 'profile') { + var ChangeDisplayName = sdk.getComponent('molecules.ChangeDisplayName'); + var ChangeAvatar = sdk.getComponent('molecules.ChangeAvatar'); + return ( +
+ Set a display name: + + Upload an avatar: + + +
+ ); } else { return (