Move init logic into componentWillMount
to simplify getInitialState
This commit is contained in:
parent
0ef5cc891e
commit
a95d8b5ed6
1 changed files with 13 additions and 12 deletions
|
@ -102,23 +102,17 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
var room;
|
|
||||||
var room_id;
|
|
||||||
if (this.props.roomAddress[0] == '!') {
|
|
||||||
room_id = this.props.roomAddress;
|
|
||||||
room = MatrixClientPeg.get().getRoom(room_id);
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
room: room,
|
room: null,
|
||||||
roomId: room_id,
|
roomId: null,
|
||||||
roomLoading: !room,
|
roomLoading: true,
|
||||||
editingRoomSettings: false,
|
editingRoomSettings: false,
|
||||||
uploadingRoomSettings: false,
|
uploadingRoomSettings: false,
|
||||||
numUnreadMessages: 0,
|
numUnreadMessages: 0,
|
||||||
draggingFile: false,
|
draggingFile: false,
|
||||||
searching: false,
|
searching: false,
|
||||||
searchResults: null,
|
searchResults: null,
|
||||||
hasUnsentMessages: this._hasUnsentMessages(room),
|
hasUnsentMessages: false,
|
||||||
callState: null,
|
callState: null,
|
||||||
guestsCanJoin: false,
|
guestsCanJoin: false,
|
||||||
canPeek: false,
|
canPeek: false,
|
||||||
|
@ -164,15 +158,22 @@ module.exports = React.createClass({
|
||||||
room: room,
|
room: room,
|
||||||
roomId: result.room_id,
|
roomId: result.room_id,
|
||||||
roomLoading: !room,
|
roomLoading: !room,
|
||||||
|
hasUnsentMessages: this._hasUnsentMessages(room),
|
||||||
}, this.updatePeeking);
|
}, this.updatePeeking);
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
roomLoading: false,
|
roomLoading: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
var room = MatrixClientPeg.get().getRoom(this.props.roomAddress);
|
||||||
|
this.setState({
|
||||||
|
roomId: this.props.roomAddress,
|
||||||
|
room: room,
|
||||||
|
roomLoading: !room,
|
||||||
|
hasUnsentMessages: this._hasUnsentMessages(room),
|
||||||
|
}, this.updatePeeking);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updatePeeking();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updatePeeking: function() {
|
updatePeeking: function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue