[FIX] Delete room error (#485)

This commit is contained in:
Diego Mello 2018-10-16 17:30:04 -03:00 committed by GitHub
parent bb8649cac4
commit 44fcb327cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 16 deletions

View File

@ -50,9 +50,8 @@ export default class RoomActionsView extends LoggedView {
super('RoomActionsView', props);
const { rid } = props;
this.rooms = database.objects('subscriptions').filtered('rid = $0', rid);
[this.room] = this.rooms;
this.state = {
room: this.room,
room: this.rooms[0] || {},
onlineMembers: [],
allMembers: [],
member: {}
@ -90,11 +89,9 @@ export default class RoomActionsView extends LoggedView {
}
get canAddUser() {
const {
rid, t
} = this.room;
const { allMembers } = this.state;
const { allMembers, room } = this.state;
const { username } = this.props;
const { rid, t } = room;
// TODO: same test joined
const userInRoom = !!allMembers.find(m => m.username === username);
@ -126,10 +123,10 @@ export default class RoomActionsView extends LoggedView {
}
get sections() {
const { onlineMembers, room } = this.state;
const {
rid, t, blocker, notifications
} = this.room;
const { onlineMembers } = this.state;
} = room;
const sections = [{
data: [{
@ -325,7 +322,7 @@ export default class RoomActionsView extends LoggedView {
}
updateRoom = () => {
this.setState({ room: this.room });
this.setState({ room: this.rooms[0] || {} });
}
toggleBlockUser = async() => {

View File

@ -52,7 +52,7 @@ export default class RoomInfoEditView extends LoggedView {
this.rooms = database.objects('subscriptions').filtered('rid = $0', rid);
this.permissions = {};
this.state = {
room: {},
room: this.rooms[0] || {},
name: '',
description: '',
topic: '',
@ -67,8 +67,8 @@ export default class RoomInfoEditView extends LoggedView {
}
async componentDidMount() {
await this.updateRoom();
componentDidMount() {
this.updateRoom();
this.init();
this.rooms.addListener(this.updateRoom);
const { room } = this.state;
@ -79,9 +79,8 @@ export default class RoomInfoEditView extends LoggedView {
this.rooms.removeAllListeners();
}
updateRoom = async() => {
const [room] = this.rooms;
await this.setState({ room });
updateRoom = () => {
this.setState({ room: this.rooms[0] || {} });
}
init = () => {

View File

@ -223,7 +223,7 @@ export default class RoomView extends LoggedView {
if (this.rooms.length > 0) {
const { room: prevRoom } = this.state;
const room = JSON.parse(JSON.stringify(this.rooms[0]));
const room = JSON.parse(JSON.stringify(this.rooms[0] || {}));
this.setState({ room });
if (!prevRoom.rid) {