Add spinner while uploading state
This commit is contained in:
parent
0b1b6057d6
commit
2bec7ec981
2 changed files with 52 additions and 13 deletions
|
@ -23,6 +23,7 @@ var MatrixClientPeg = require("../../../../src/MatrixClientPeg");
|
||||||
var ComponentBroker = require('../../../../src/ComponentBroker');
|
var ComponentBroker = require('../../../../src/ComponentBroker');
|
||||||
var classNames = require("classnames");
|
var classNames = require("classnames");
|
||||||
var filesize = require('filesize');
|
var filesize = require('filesize');
|
||||||
|
var q = require('q');
|
||||||
|
|
||||||
var MessageTile = ComponentBroker.get('molecules/MessageTile');
|
var MessageTile = ComponentBroker.get('molecules/MessageTile');
|
||||||
var RoomHeader = ComponentBroker.get('molecules/RoomHeader');
|
var RoomHeader = ComponentBroker.get('molecules/RoomHeader');
|
||||||
|
@ -44,7 +45,10 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onSaveClick: function() {
|
onSaveClick: function() {
|
||||||
this.setState({editingRoomSettings: false});
|
this.setState({
|
||||||
|
editingRoomSettings: false,
|
||||||
|
uploadingRoomSettings: true,
|
||||||
|
});
|
||||||
|
|
||||||
var new_name = this.refs.header.getRoomName();
|
var new_name = this.refs.header.getRoomName();
|
||||||
var new_topic = this.refs.room_settings.getTopic();
|
var new_topic = this.refs.room_settings.getTopic();
|
||||||
|
@ -75,36 +79,65 @@ module.exports = React.createClass({
|
||||||
old_history_visibility = "shared";
|
old_history_visibility = "shared";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var deferreds = [];
|
||||||
|
|
||||||
if (old_name != new_name && new_name != undefined) {
|
if (old_name != new_name && new_name != undefined) {
|
||||||
MatrixClientPeg.get().setRoomName(this.state.room.roomId, new_name);
|
deferreds.push(
|
||||||
|
MatrixClientPeg.get().setRoomName(this.state.room.roomId, new_name)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old_topic != new_topic && new_topic != undefined) {
|
if (old_topic != new_topic && new_topic != undefined) {
|
||||||
MatrixClientPeg.get().setRoomTopic(this.state.room.roomId, new_topic);
|
deferreds.push(
|
||||||
|
MatrixClientPeg.get().setRoomTopic(this.state.room.roomId, new_topic)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old_join_rule != new_join_rule && new_join_rule != undefined) {
|
if (old_join_rule != new_join_rule && new_join_rule != undefined) {
|
||||||
|
deferreds.push(
|
||||||
MatrixClientPeg.get().sendStateEvent(
|
MatrixClientPeg.get().sendStateEvent(
|
||||||
this.state.room.roomId, "m.room.join_rules", {
|
this.state.room.roomId, "m.room.join_rules", {
|
||||||
join_rule: new_join_rule,
|
join_rule: new_join_rule,
|
||||||
}, ""
|
}, ""
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old_history_visibility != new_history_visibility && new_history_visibility != undefined) {
|
if (old_history_visibility != new_history_visibility && new_history_visibility != undefined) {
|
||||||
|
deferreds.push(
|
||||||
MatrixClientPeg.get().sendStateEvent(
|
MatrixClientPeg.get().sendStateEvent(
|
||||||
this.state.room.roomId, "m.room.history_visibility", {
|
this.state.room.roomId, "m.room.history_visibility", {
|
||||||
history_visibility: new_history_visibility,
|
history_visibility: new_history_visibility,
|
||||||
}, ""
|
}, ""
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_power_levels) {
|
if (new_power_levels) {
|
||||||
|
deferreds.push(
|
||||||
MatrixClientPeg.get().sendStateEvent(
|
MatrixClientPeg.get().sendStateEvent(
|
||||||
this.state.room.roomId, "m.room.power_levels", new_power_levels, ""
|
this.state.room.roomId, "m.room.power_levels", new_power_levels, ""
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("deferreds " + deferreds.length);
|
||||||
|
|
||||||
|
if (deferreds.length) {
|
||||||
|
var self = this;
|
||||||
|
q.all(deferreds).fail(function(err) {
|
||||||
|
// TODO: Handle err
|
||||||
|
}).finally(function() {
|
||||||
|
self.setState({
|
||||||
|
uploadingRoomSettings: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
editingRoomSettings: false,
|
||||||
|
uploadingRoomSettings: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
@ -179,6 +212,11 @@ module.exports = React.createClass({
|
||||||
roomEdit = <RoomSettings ref="room_settings" room={this.state.room} />;
|
roomEdit = <RoomSettings ref="room_settings" room={this.state.room} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.state.uploadingRoomSettings) {
|
||||||
|
console.log("Uploading");
|
||||||
|
roomEdit = <Loader/>;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_RoomView">
|
<div className="mx_RoomView">
|
||||||
<RoomHeader ref="header" room={this.state.room} editing={this.state.editingRoomSettings}
|
<RoomHeader ref="header" room={this.state.room} editing={this.state.editingRoomSettings}
|
||||||
|
|
|
@ -46,6 +46,7 @@ module.exports = {
|
||||||
room: this.props.roomId ? MatrixClientPeg.get().getRoom(this.props.roomId) : null,
|
room: this.props.roomId ? MatrixClientPeg.get().getRoom(this.props.roomId) : null,
|
||||||
messageCap: INITIAL_SIZE,
|
messageCap: INITIAL_SIZE,
|
||||||
editingRoomSettings: false,
|
editingRoomSettings: false,
|
||||||
|
uploadingRoomSettings: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue