mirror of https://github.com/vector-im/riot-web
factor out room-leaving code into MatrixChat for now, and add a dedicated leave button in to the header bar for now
parent
43ab6074c9
commit
6ad6ed2a49
|
@ -29,6 +29,7 @@ var Login = require("./login/Login");
|
||||||
var Registration = require("./login/Registration");
|
var Registration = require("./login/Registration");
|
||||||
var PostRegistration = require("./login/PostRegistration");
|
var PostRegistration = require("./login/PostRegistration");
|
||||||
|
|
||||||
|
var Modal = require("../../Modal");
|
||||||
var sdk = require('../../index');
|
var sdk = require('../../index');
|
||||||
var MatrixTools = require('../../MatrixTools');
|
var MatrixTools = require('../../MatrixTools');
|
||||||
var linkifyMatrix = require("../../linkify-matrix");
|
var linkifyMatrix = require("../../linkify-matrix");
|
||||||
|
@ -200,6 +201,36 @@ module.exports = React.createClass({
|
||||||
self.setState({errorText: 'Login failed.'});
|
self.setState({errorText: 'Login failed.'});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'leave_room':
|
||||||
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
|
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
||||||
|
|
||||||
|
var roomId = payload.room_id;
|
||||||
|
Modal.createDialog(QuestionDialog, {
|
||||||
|
title: "Leave room",
|
||||||
|
description: "Are you sure you want to leave the room?",
|
||||||
|
onFinished: function(should_leave) {
|
||||||
|
if (should_leave) {
|
||||||
|
var d = MatrixClientPeg.get().leave(roomId);
|
||||||
|
|
||||||
|
// FIXME: controller shouldn't be loading a view :(
|
||||||
|
var Loader = sdk.getComponent("elements.Spinner");
|
||||||
|
var modal = Modal.createDialog(Loader);
|
||||||
|
|
||||||
|
d.then(function() {
|
||||||
|
modal.close();
|
||||||
|
dis.dispatch({action: 'view_next_room'});
|
||||||
|
}, function(err) {
|
||||||
|
modal.close();
|
||||||
|
Modal.createDialog(ErrorDialog, {
|
||||||
|
title: "Failed to leave room",
|
||||||
|
description: err.toString()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 'view_room':
|
case 'view_room':
|
||||||
this.focusComposer = true;
|
this.focusComposer = true;
|
||||||
|
|
|
@ -793,6 +793,14 @@ module.exports = React.createClass({
|
||||||
this.setState(this.getInitialState());
|
this.setState(this.getInitialState());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onLeaveClick: function() {
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'leave_room',
|
||||||
|
room_id: this.props.roomId,
|
||||||
|
});
|
||||||
|
this.props.onFinished();
|
||||||
|
},
|
||||||
|
|
||||||
onRejectButtonClicked: function(ev) {
|
onRejectButtonClicked: function(ev) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -853,7 +861,7 @@ module.exports = React.createClass({
|
||||||
// XXX: this is a bit of a hack and might possibly cause the video to push out the page anyway
|
// XXX: this is a bit of a hack and might possibly cause the video to push out the page anyway
|
||||||
// but it's better than the video going missing entirely
|
// but it's better than the video going missing entirely
|
||||||
if (auxPanelMaxHeight < 50) auxPanelMaxHeight = 50;
|
if (auxPanelMaxHeight < 50) auxPanelMaxHeight = 50;
|
||||||
|
|
||||||
video.style.maxHeight = auxPanelMaxHeight + "px";
|
video.style.maxHeight = auxPanelMaxHeight + "px";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1039,7 +1047,7 @@ module.exports = React.createClass({
|
||||||
return (
|
return (
|
||||||
<div className="mx_RoomView">
|
<div className="mx_RoomView">
|
||||||
<RoomHeader ref="header" room={this.state.room} searchInfo={searchInfo} editing={this.state.editingRoomSettings} onSearchClick={this.onSearchClick}
|
<RoomHeader ref="header" room={this.state.room} searchInfo={searchInfo} editing={this.state.editingRoomSettings} onSearchClick={this.onSearchClick}
|
||||||
onSettingsClick={this.onSettingsClick} onSaveClick={this.onSaveClick} onCancelClick={this.onCancelClick} />
|
onSettingsClick={this.onSettingsClick} onSaveClick={this.onSaveClick} onCancelClick={this.onCancelClick} onLeaveClick={this.onLeaveClick} />
|
||||||
{ fileDropTarget }
|
{ fileDropTarget }
|
||||||
<div className="mx_RoomView_auxPanel">
|
<div className="mx_RoomView_auxPanel">
|
||||||
<CallView ref="callView" room={this.state.room} ConferenceHandler={this.props.ConferenceHandler}/>
|
<CallView ref="callView" room={this.state.room} ConferenceHandler={this.props.ConferenceHandler}/>
|
||||||
|
|
|
@ -226,36 +226,10 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: this is horribly duplicated with MemberTile's onLeaveClick.
|
|
||||||
// Not sure what the right solution to this is.
|
|
||||||
onLeaveClick: function() {
|
onLeaveClick: function() {
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
dis.dispatch({
|
||||||
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
action: 'leave_room',
|
||||||
|
room_id: this.props.member.roomId,
|
||||||
var roomId = this.props.member.roomId;
|
|
||||||
Modal.createDialog(QuestionDialog, {
|
|
||||||
title: "Leave room",
|
|
||||||
description: "Are you sure you want to leave the room?",
|
|
||||||
onFinished: function(should_leave) {
|
|
||||||
if (should_leave) {
|
|
||||||
var d = MatrixClientPeg.get().leave(roomId);
|
|
||||||
|
|
||||||
// FIXME: controller shouldn't be loading a view :(
|
|
||||||
var Loader = sdk.getComponent("elements.Spinner");
|
|
||||||
var modal = Modal.createDialog(Loader);
|
|
||||||
|
|
||||||
d.then(function() {
|
|
||||||
modal.close();
|
|
||||||
dis.dispatch({action: 'view_next_room'});
|
|
||||||
}, function(err) {
|
|
||||||
modal.close();
|
|
||||||
Modal.createDialog(ErrorDialog, {
|
|
||||||
title: "Failed to leave room",
|
|
||||||
description: err.toString()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.props.onFinished();
|
this.props.onFinished();
|
||||||
},
|
},
|
||||||
|
|
|
@ -31,33 +31,11 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onLeaveClick: function() {
|
onLeaveClick: function() {
|
||||||
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
dis.dispatch({
|
||||||
|
action: 'leave_room',
|
||||||
var roomId = this.props.member.roomId;
|
room_id: this.props.member.roomId,
|
||||||
Modal.createDialog(QuestionDialog, {
|
|
||||||
title: "Leave room",
|
|
||||||
description: "Are you sure you want to leave the room?",
|
|
||||||
onFinished: function(should_leave) {
|
|
||||||
if (should_leave) {
|
|
||||||
var d = MatrixClientPeg.get().leave(roomId);
|
|
||||||
|
|
||||||
// FIXME: controller shouldn't be loading a view :(
|
|
||||||
var Loader = sdk.getComponent("elements.Spinner");
|
|
||||||
var modal = Modal.createDialog(Loader);
|
|
||||||
|
|
||||||
d.then(function() {
|
|
||||||
modal.close();
|
|
||||||
dis.dispatch({action: 'view_next_room'});
|
|
||||||
}, function(err) {
|
|
||||||
modal.close();
|
|
||||||
Modal.createDialog(ErrorDialog, {
|
|
||||||
title: "Failed to leave room",
|
|
||||||
description: err.toString()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
this.props.onFinished();
|
||||||
},
|
},
|
||||||
|
|
||||||
shouldComponentUpdate: function(nextProps, nextState) {
|
shouldComponentUpdate: function(nextProps, nextState) {
|
||||||
|
|
|
@ -35,6 +35,8 @@ module.exports = React.createClass({
|
||||||
editing: React.PropTypes.bool,
|
editing: React.PropTypes.bool,
|
||||||
onSettingsClick: React.PropTypes.func,
|
onSettingsClick: React.PropTypes.func,
|
||||||
onSaveClick: React.PropTypes.func,
|
onSaveClick: React.PropTypes.func,
|
||||||
|
onSearchClick: React.PropTypes.func,
|
||||||
|
onLeaveClick: React.PropTypes.func,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
|
@ -251,6 +253,14 @@ module.exports = React.createClass({
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var exit_button;
|
||||||
|
if (this.props.onLeaveClick) {
|
||||||
|
exit_button =
|
||||||
|
<div className="mx_RoomHeader_button mx_RoomHeader_leaveButton">
|
||||||
|
<img src="img/leave.svg" title="Leave room" alt="Leave room" width="26" height="20" onClick={this.props.onLeaveClick}/>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
header =
|
header =
|
||||||
<div className="mx_RoomHeader_wrapper">
|
<div className="mx_RoomHeader_wrapper">
|
||||||
<div className="mx_RoomHeader_leftRow">
|
<div className="mx_RoomHeader_leftRow">
|
||||||
|
@ -269,6 +279,7 @@ module.exports = React.createClass({
|
||||||
{ video_button }
|
{ video_button }
|
||||||
{ voice_button }
|
{ voice_button }
|
||||||
{ zoom_button }
|
{ zoom_button }
|
||||||
|
{ exit_button }
|
||||||
<div className="mx_RoomHeader_button">
|
<div className="mx_RoomHeader_button">
|
||||||
<img src="img/search.svg" title="Search" alt="Search" width="21" height="19" onClick={this.props.onSearchClick}/>
|
<img src="img/search.svg" title="Search" alt="Search" width="21" height="19" onClick={this.props.onSearchClick}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue