Pass the invited email through to RoomPreviewBar, display it in a temporary way currently.

Remove a condition from RoomView render that appears to be functionally identical to the previous.
This commit is contained in:
David Baker 2016-03-17 18:38:25 +00:00
parent a13513935b
commit f1844a99e7
3 changed files with 47 additions and 22 deletions

View file

@ -390,7 +390,7 @@ module.exports = React.createClass({
case 'view_room':
this._viewRoom(
payload.room_id, payload.room_alias, payload.show_settings, payload.event_id,
payload.invite_sign_url, payload.oob_data
payload.third_party_invite, payload.oob_data
);
break;
case 'view_prev_room':
@ -437,7 +437,7 @@ module.exports = React.createClass({
room_id: foundRoom.roomId,
room_alias: payload.room_alias,
event_id: payload.event_id,
invite_sign_url: payload.invite_sign_url,
third_party_invite: payload.third_party_invite,
oob_data: payload.oob_data,
});
return;
@ -450,7 +450,7 @@ module.exports = React.createClass({
room_id: result.room_id,
room_alias: payload.room_alias,
event_id: payload.event_id,
invite_sign_url: payload.invite_sign_url,
third_party_invite: payload.third_party_invite,
oob_data: payload.oob_data,
});
});
@ -539,10 +539,14 @@ module.exports = React.createClass({
//
// eventId is optional and will cause a switch to the context of that
// particular event.
// @param {Object} thirdPartyInvite Object containing data about the third party
// we received to join the room, if any.
// @param {Object} thirdPartyInvite.inviteSignUrl 3pid invite sign URL
// @param {Object} thirdPartyInvite.invitedwithEmail The email address the invite was sent to
// @param {Object} oob_data Object of additional data about the room
// that has been passed out-of-band (eg.
// room name and avatar from an invite email)
_viewRoom: function(roomId, roomAlias, showSettings, eventId, invite_sign_url, oob_data) {
_viewRoom: function(roomId, roomAlias, showSettings, eventId, thirdPartyInvite, oob_data) {
// before we switch room, record the scroll state of the current room
this._updateScrollMap();
@ -555,7 +559,7 @@ module.exports = React.createClass({
highlightedEventId: eventId,
initialEventPixelOffset: undefined,
page_type: this.PageTypes.RoomView,
inviteSignUrl: invite_sign_url,
thirdPartyInvite: thirdPartyInvite,
roomOobData: oob_data,
};
@ -783,6 +787,11 @@ module.exports = React.createClass({
var roomString = segments[0];
var eventId = segments[1]; // undefined if no event id given
// FIXME: sort_out caseConsistency
var third_party_invite = {
inviteSignUrl: params.signurl,
invitedEmail: params.email,
};
var oob_data = {
name: params.room_name,
avatarUrl: params.room_avatar_url,
@ -794,7 +803,7 @@ module.exports = React.createClass({
action: 'view_room_alias',
room_alias: roomString,
event_id: eventId,
invite_sign_url: params.signurl,
third_party_invite: third_party_invite,
oob_data: oob_data,
});
} else {
@ -802,7 +811,7 @@ module.exports = React.createClass({
action: 'view_room',
room_id: roomString,
event_id: eventId,
invite_sign_url: params.signurl,
third_party_invite: third_party_invite,
oob_data: oob_data,
});
}
@ -1009,7 +1018,7 @@ module.exports = React.createClass({
roomId={this.state.currentRoom}
roomAlias={this.state.currentRoomAlias}
eventId={this.state.initialEventId}
inviteSignUrl={this.state.inviteSignUrl}
thirdPartyInvite={this.state.thirdPartyInvite}
oobData={this.state.roomOobData}
highlightedEventId={this.state.highlightedEventId}
eventPixelOffset={this.state.initialEventPixelOffset}

View file

@ -60,9 +60,12 @@ module.exports = React.createClass({
// useful for joining rooms by alias correctly (and fixing https://github.com/vector-im/vector-web/issues/819)
roomAlias: React.PropTypes.string,
// The URL used to join this room from an email invite
// (given as part of the link in the invite email)
inviteSignUrl: React.PropTypes.string,
// An object representing a third party invite to join this room
// Fields:
// * inviteSignUrl (string) The URL used to join this room from an email invite
// (given as part of the link in the invite email)
// * invitedEmail (string) The email address that was invited to this room
thirdPartyInvite: React.PropTypes.object,
// Any data about the room that would normally come from the Home Server
// but has been passed out-of-band, eg. the room name and avatar URL
@ -538,8 +541,9 @@ module.exports = React.createClass({
}
display_name_promise.then(() => {
var sign_url = this.props.thirdPartyInvite ? this.props.thirdPartyInvite.inviteSignUrl : undefined;
return MatrixClientPeg.get().joinRoom(this.props.roomAlias || this.props.roomId,
{ inviteSignUrl: this.props.inviteSignUrl } )
{ inviteSignUrl: sign_url } )
}).done(function() {
// It is possible that there is no Room yet if state hasn't come down
// from /sync - joinRoom will resolve when the HTTP request to join succeeds,
@ -1097,7 +1101,13 @@ module.exports = React.createClass({
if (this.props.oobData) {
inviterName = this.props.oobData.inviterName;
}
var invitedEmail = undefined;
if (this.props.thirdPartyInvite) {
invitedEmail = this.props.thirdPartyInvite.invitedEmail;
}
// We have no room object for this room, only the ID.
// We've got to this room by following a link, possibly a third party invite.
return (
<div className="mx_RoomView">
<RoomHeader ref="header" room={this.state.room} oobData={this.props.oobData} />
@ -1107,6 +1117,7 @@ module.exports = React.createClass({
canJoin={ true } canPreview={ false }
spinner={this.state.joining}
inviterName={inviterName}
invitedEmail={invitedEmail}
/>
</div>
<div className="mx_RoomView_messagePanel"></div>
@ -1138,6 +1149,7 @@ module.exports = React.createClass({
// as they could be a spam vector.
// XXX: in future we could give the option of a 'Preview' button which lets them view anyway.
// We have a regular invite for this room.
return (
<div className="mx_RoomView">
<RoomHeader ref="header" room={this.state.room}/>
@ -1208,24 +1220,24 @@ module.exports = React.createClass({
else if (this.state.searching) {
aux = <SearchBar ref="search_bar" searchInProgress={this.state.searchInProgress } onCancelClick={this.onCancelSearchClick} onSearch={this.onSearch}/>;
}
else if (this.state.guestsCanJoin && MatrixClientPeg.get().isGuest() &&
(!myMember || myMember.membership !== "join")) {
else if (!myMember || myMember.membership !== "join") {
var inviterName = undefined;
if (this.props.oobData) {
inviterName = this.props.oobData.inviterName;
}
var invitedEmail = undefined;
if (this.props.thirdPartyInvite) {
invitedEmail = this.props.thirdPartyInvite.invitedEmail;
}
// We do have a room object for this room, but we're not currently in it.
// We may have a 3rd party invite to it.
aux = (
<RoomPreviewBar onJoinClick={this.onJoinButtonClicked} canJoin={true}
onRejectClick={ this.onRejectThreepidInviteButtonClicked }
onRejectClick={this.onRejectThreepidInviteButtonClicked}
spinner={this.state.joining}
inviterName={inviterName}
/>
);
}
else if (!myMember || myMember.membership !== "join") {
aux = (
<RoomPreviewBar onJoinClick={this.onJoinButtonClicked} canJoin={true}
spinner={this.state.joining} canPreview={ this.state.canPeek }
invitedEmail={invitedEmail}
canPreview={this.state.canPeek}
/>
);
}

View file

@ -29,6 +29,9 @@ module.exports = React.createClass({
// if inviterName is specified, the preview bar will shown an invite to the room.
// You should also specify onRejectClick if specifiying inviterName
inviterName: React.PropTypes.string,
// If invited by 3rd party invite, the email address the invite was sent to
invitedEmail: React.PropTypes.string,
canJoin: React.PropTypes.bool,
canPreview: React.PropTypes.bool,
spinner: React.PropTypes.bool,
@ -61,6 +64,7 @@ module.exports = React.createClass({
<div className="mx_RoomPreviewBar_join_text">
Would you like to <a onClick={ this.props.onJoinClick }>accept</a> or <a onClick={ this.props.onRejectClick }>decline</a> this invitation?
</div>
<div>{this.props.invitedEmail} was invited</div>
</div>
);