From d46e42f8e77e76386ee36c805bcdd08537a5ad55 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 20 Nov 2015 11:57:04 +0000 Subject: [PATCH 1/3] Have a post-registration screen. Fix race in ChangeAvatar where if you hadn't got an initial avatar downloaded yet you couldn't update it after the component loaded. --- src/controllers/molecules/ChangeAvatar.js | 10 ++++++++ .../molecules/ChangeDisplayName.js | 6 ++++- src/controllers/pages/MatrixChat.js | 23 ++++++++++++------- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/controllers/molecules/ChangeAvatar.js b/src/controllers/molecules/ChangeAvatar.js index 093badfe8f..7e8f959ebf 100644 --- a/src/controllers/molecules/ChangeAvatar.js +++ b/src/controllers/molecules/ChangeAvatar.js @@ -36,6 +36,16 @@ module.exports = { } }, + componentWillReceiveProps: function(newProps) { + if (this.avatarSet) { + // don't clobber what the user has just set + return; + } + this.setState({ + avatarUrl: newProps.initialAvatarUrl + }); + }, + setAvatarFromFile: function(file) { var newUrl = null; diff --git a/src/controllers/molecules/ChangeDisplayName.js b/src/controllers/molecules/ChangeDisplayName.js index 7e49b8f725..afef82772c 100644 --- a/src/controllers/molecules/ChangeDisplayName.js +++ b/src/controllers/molecules/ChangeDisplayName.js @@ -15,10 +15,14 @@ limitations under the License. */ 'use strict'; - +var React = require('react'); var MatrixClientPeg = require("../../MatrixClientPeg"); module.exports = { + propTypes: { + onFinished: React.PropTypes.func + }, + getDefaultProps: function() { return { onFinished: function() {}, diff --git a/src/controllers/pages/MatrixChat.js b/src/controllers/pages/MatrixChat.js index 4655011a45..e31496afc0 100644 --- a/src/controllers/pages/MatrixChat.js +++ b/src/controllers/pages/MatrixChat.js @@ -31,7 +31,7 @@ module.exports = { RoomView: "room_view", UserSettings: "user_settings", CreateRoom: "create_room", - RoomDirectory: "room_directory", + RoomDirectory: "room_directory" }, AuxPanel: { @@ -144,6 +144,11 @@ module.exports = { }); this.notifyNewScreen('login'); break; + case 'start_post_registration': + this.setState({ // don't clobber logged_in status + screen: 'post_registration' + }); + break; case 'token_login': if (this.state.logged_in) return; @@ -298,13 +303,11 @@ module.exports = { }, onLoggedIn: function(credentials) { - if (credentials) { // registration doesn't do this yet - console.log("onLoggedIn => %s", credentials.userId); - MatrixClientPeg.replaceUsingAccessToken( - credentials.homeserverUrl, credentials.identityServerUrl, - credentials.userId, credentials.accessToken - ); - } + console.log("onLoggedIn => %s", credentials.userId); + MatrixClientPeg.replaceUsingAccessToken( + credentials.homeserverUrl, credentials.identityServerUrl, + credentials.userId, credentials.accessToken + ); this.setState({ screen: undefined, logged_in: true @@ -431,6 +434,10 @@ module.exports = { dis.dispatch({ action: 'view_room_directory', }); + } else if (screen == 'post_registration') { + dis.dispatch({ + action: 'start_post_registration', + }); } else if (screen.indexOf('room/') == 0) { var roomString = screen.split('/')[1]; if (roomString[0] == '#') { From 1a72cb56c670d82804045a552a866205b5829be5 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 20 Nov 2015 14:26:49 +0000 Subject: [PATCH 2/3] Log an error for unknown screens --- src/controllers/pages/MatrixChat.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/controllers/pages/MatrixChat.js b/src/controllers/pages/MatrixChat.js index e31496afc0..66e359a711 100644 --- a/src/controllers/pages/MatrixChat.js +++ b/src/controllers/pages/MatrixChat.js @@ -459,6 +459,9 @@ module.exports = { }); } } + else { + console.error("Unknown screen : %s", screen); + } }, notifyNewScreen: function(screen) { From 032fdc0abc76e38ad976e864258764b0bc0eeed8 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 20 Nov 2015 14:32:00 +0000 Subject: [PATCH 3/3] Remove diff clutter --- src/controllers/pages/MatrixChat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/pages/MatrixChat.js b/src/controllers/pages/MatrixChat.js index 66e359a711..af2c78ff26 100644 --- a/src/controllers/pages/MatrixChat.js +++ b/src/controllers/pages/MatrixChat.js @@ -31,7 +31,7 @@ module.exports = { RoomView: "room_view", UserSettings: "user_settings", CreateRoom: "create_room", - RoomDirectory: "room_directory" + RoomDirectory: "room_directory", }, AuxPanel: {