diff --git a/app/views/NotificationPreferencesView/index.js b/app/views/NotificationPreferencesView/index.js index d5e3f6058..423d2a7fb 100644 --- a/app/views/NotificationPreferencesView/index.js +++ b/app/views/NotificationPreferencesView/index.js @@ -114,7 +114,9 @@ export default class NotificationPreferencesView extends React.Component { this.mounted = false; this.rid = props.navigation.getParam('rid'); const room = props.navigation.getParam('room'); - + this.state = { + room: room || {} + }; if (room && room.observe) { this.roomObservable = room.observe(); this.subscription = this.roomObservable @@ -126,10 +128,6 @@ export default class NotificationPreferencesView extends React.Component { } }); } - - this.state = { - room: room || {} - }; } componentDidMount() { diff --git a/app/views/RoomActionsView/index.js b/app/views/RoomActionsView/index.js index b039fe17d..d1e96ac28 100644 --- a/app/views/RoomActionsView/index.js +++ b/app/views/RoomActionsView/index.js @@ -43,19 +43,6 @@ class RoomActionsView extends React.Component { super(props); this.mounted = false; const room = props.navigation.getParam('room'); - - if (room && room.observe) { - this.roomObservable = room.observe(); - this.subscription = this.roomObservable - .subscribe((changes) => { - if (this.mounted) { - this.setState({ room: changes }); - } else { - this.state.room = changes; - } - }); - } - this.rid = props.navigation.getParam('rid'); this.t = props.navigation.getParam('t'); this.state = { @@ -67,6 +54,17 @@ class RoomActionsView extends React.Component { canAutoTranslate: false, canAddUser: false }; + if (room && room.observe) { + this.roomObservable = room.observe(); + this.subscription = this.roomObservable + .subscribe((changes) => { + if (this.mounted) { + this.setState({ room: changes }); + } else { + this.state.room = changes; + } + }); + } } async componentDidMount() { diff --git a/app/views/RoomMembersView/index.js b/app/views/RoomMembersView/index.js index 786059b8a..25476297b 100644 --- a/app/views/RoomMembersView/index.js +++ b/app/views/RoomMembersView/index.js @@ -57,20 +57,7 @@ class RoomMembersView extends React.Component { this.MUTE_INDEX = 1; this.actionSheetOptions = ['']; const { rid } = props.navigation.state.params; - const room = props.navigation.getParam('room'); - if (room && room.observe) { - this.roomObservable = room.observe(); - this.subscription = this.roomObservable - .subscribe((changes) => { - if (this.mounted) { - this.setState({ room: changes }); - } else { - this.state.room = changes; - } - }); - } - this.state = { isLoading: false, allUsers: false, @@ -82,6 +69,17 @@ class RoomMembersView extends React.Component { room: room || {}, end: false }; + if (room && room.observe) { + this.roomObservable = room.observe(); + this.subscription = this.roomObservable + .subscribe((changes) => { + if (this.mounted) { + this.setState({ room: changes }); + } else { + this.state.room = changes; + } + }); + } } async componentDidMount() { diff --git a/app/views/RoomView/UploadProgress.js b/app/views/RoomView/UploadProgress.js index 4ef471dec..d4f1c398b 100644 --- a/app/views/RoomView/UploadProgress.js +++ b/app/views/RoomView/UploadProgress.js @@ -76,10 +76,10 @@ class UploadProgress extends Component { super(props); this.mounted = false; this.ranInitialUploadCheck = false; - this.init(); this.state = { uploads: [] }; + this.init(); } componentDidMount() { diff --git a/app/views/ThreadMessagesView/index.js b/app/views/ThreadMessagesView/index.js index 508bf630f..05e6c7821 100644 --- a/app/views/ThreadMessagesView/index.js +++ b/app/views/ThreadMessagesView/index.js @@ -43,12 +43,12 @@ class ThreadMessagesView extends React.Component { this.mounted = false; this.rid = props.navigation.getParam('rid'); this.t = props.navigation.getParam('t'); - this.subscribeData(); this.state = { loading: false, end: false, messages: [] }; + this.subscribeData(); } componentDidMount() {