diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js
index ff864379fa..a081ce6fe7 100644
--- a/src/components/structures/MatrixChat.js
+++ b/src/components/structures/MatrixChat.js
@@ -139,6 +139,10 @@ module.exports = React.createClass({
register_hs_url: null,
register_is_url: null,
register_id_sid: null,
+
+ // Whether a DM should be created with welcomeUserId (prop) on registration
+ // see _onLoggedIn
+ shouldCreateWelcomeDm: true,
};
return s;
},
@@ -378,6 +382,11 @@ module.exports = React.createClass({
});
this.notifyNewScreen('forgot_password');
break;
+ case 'start_chat':
+ createRoom({
+ dmUserId: payload.user_id,
+ });
+ break;
case 'leave_room':
this._leaveRoom(payload.room_id);
break;
@@ -474,6 +483,9 @@ module.exports = React.createClass({
case 'view_set_mxid':
this._setMxId();
break;
+ case 'view_start_chat_or_reuse':
+ this._chatCreateOrReuse(payload.user_id);
+ break;
case 'view_create_chat':
this._createChat();
break;
@@ -707,6 +719,50 @@ module.exports = React.createClass({
});
},
+ _chatCreateOrReuse: function(userId) {
+ const ChatCreateOrReuseDialog = sdk.getComponent(
+ 'views.dialogs.ChatCreateOrReuseDialog',
+ );
+ if (MatrixClientPeg.get().isGuest()) {
+ dis.dispatch({
+ action: 'do_after_sync_prepared',
+ deferred_action: {
+ action: 'view_start_chat_or_reuse',
+ user_id: userId,
+ },
+ });
+ dis.dispatch({
+ action: 'view_set_mxid',
+ });
+ return;
+ }
+
+ const close = Modal.createDialog(ChatCreateOrReuseDialog, {
+ userId: userId,
+ onFinished: (success) => {
+ if (!success) {
+ // Dialog cancelled, default to home
+ dis.dispatch({ action: 'view_home_page' });
+ }
+ },
+ onNewDMClick: () => {
+ dis.dispatch({
+ action: 'start_chat',
+ user_id: userId,
+ });
+ // Close the dialog, indicate success (calls onFinished(true))
+ close(true);
+ },
+ onExistingRoomSelected: (roomId) => {
+ dis.dispatch({
+ action: 'view_room',
+ room_id: roomId,
+ });
+ close(true);
+ },
+ }).close;
+ },
+
_invite: function(roomId) {
const ChatInviteDialog = sdk.getComponent("dialogs.ChatInviteDialog");
Modal.createDialog(ChatInviteDialog, {
@@ -838,7 +894,7 @@ module.exports = React.createClass({
MatrixClientPeg.get().getUserIdLocalpart()
);
- if (this.props.config.welcomeUserId) {
+ if (this.props.config.welcomeUserId && this.state.shouldCreateWelcomeDm) {
createRoom({
dmUserId: this.props.config.welcomeUserId,
andView: false,
@@ -1043,6 +1099,12 @@ module.exports = React.createClass({
}
} else if (screen.indexOf('user/') == 0) {
const userId = screen.substring(5);
+
+ if (params.action === 'chat') {
+ this._chatCreateOrReuse(userId);
+ return;
+ }
+
this.setState({ viewUserId: userId });
this._setPage(PageTypes.UserView);
this.notifyNewScreen('user/' + userId);
diff --git a/src/components/views/avatars/BaseAvatar.js b/src/components/views/avatars/BaseAvatar.js
index 65730be40b..a4443430f4 100644
--- a/src/components/views/avatars/BaseAvatar.js
+++ b/src/components/views/avatars/BaseAvatar.js
@@ -32,6 +32,7 @@ module.exports = React.createClass({
urls: React.PropTypes.array, // [highest_priority, ... , lowest_priority]
width: React.PropTypes.number,
height: React.PropTypes.number,
+ // XXX resizeMethod not actually used.
resizeMethod: React.PropTypes.string,
defaultToInitialLetter: React.PropTypes.bool // true to add default url
},
diff --git a/src/components/views/dialogs/ChatCreateOrReuseDialog.js b/src/components/views/dialogs/ChatCreateOrReuseDialog.js
index f563af6691..93ebf8cc2f 100644
--- a/src/components/views/dialogs/ChatCreateOrReuseDialog.js
+++ b/src/components/views/dialogs/ChatCreateOrReuseDialog.js
@@ -18,34 +18,30 @@ import React from 'react';
import sdk from '../../../index';
import dis from '../../../dispatcher';
import MatrixClientPeg from '../../../MatrixClientPeg';
+import { _t } from '../../../languageHandler';
import DMRoomMap from '../../../utils/DMRoomMap';
import AccessibleButton from '../elements/AccessibleButton';
import Unread from '../../../Unread';
import classNames from 'classnames';
import createRoom from '../../../createRoom';
+import { RoomMember } from "matrix-js-sdk";
export default class ChatCreateOrReuseDialog extends React.Component {
constructor(props) {
super(props);
- this.onNewDMClick = this.onNewDMClick.bind(this);
this.onRoomTileClick = this.onRoomTileClick.bind(this);
+
+ this.state = {
+ tiles: [],
+ profile: {
+ displayName: null,
+ avatarUrl: null,
+ },
+ };
}
- onNewDMClick() {
- createRoom({dmUserId: this.props.userId});
- this.props.onFinished(true);
- }
-
- onRoomTileClick(roomId) {
- dis.dispatch({
- action: 'view_room',
- room_id: roomId,
- });
- this.props.onFinished(true);
- }
-
- render() {
+ componentWillMount() {
const client = MatrixClientPeg.get();
const dmRoomMap = new DMRoomMap(client);
@@ -70,40 +66,115 @@ export default class ChatCreateOrReuseDialog extends React.Component {
highlight={highlight}
isInvite={me.membership == "invite"}
onClick={this.onRoomTileClick}
- />
+ />,
);
}
}
- const labelClasses = classNames({
- mx_MemberInfo_createRoom_label: true,
- mx_RoomTile_name: true,
+ this.setState({
+ tiles: tiles,
});
- const startNewChat =
+ { _t('Click on the button below to start chatting!') } +
+ { profile } +