[FIX] Form re-rendering on RoomInfoEditView when app receives newer data from stream (#4220)
This commit is contained in:
parent
748e87acf3
commit
d47320733a
|
@ -6,7 +6,6 @@ import isEmpty from 'lodash/isEmpty';
|
||||||
import { Alert, Keyboard, ScrollView, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
import { Alert, Keyboard, ScrollView, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||||
import ImagePicker, { Image } from 'react-native-image-crop-picker';
|
import ImagePicker, { Image } from 'react-native-image-crop-picker';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { Subscription } from 'rxjs';
|
|
||||||
|
|
||||||
import { deleteRoom } from '../../actions/room';
|
import { deleteRoom } from '../../actions/room';
|
||||||
import { themes } from '../../lib/constants';
|
import { themes } from '../../lib/constants';
|
||||||
|
@ -86,7 +85,6 @@ interface IRoomInfoEditViewProps extends IBaseScreen<ChatsStackParamList | Modal
|
||||||
|
|
||||||
class RoomInfoEditView extends React.Component<IRoomInfoEditViewProps, IRoomInfoEditViewState> {
|
class RoomInfoEditView extends React.Component<IRoomInfoEditViewProps, IRoomInfoEditViewState> {
|
||||||
randomValue = random(15);
|
randomValue = random(15);
|
||||||
private querySubscription: Subscription | undefined;
|
|
||||||
private room: TSubscriptionModel;
|
private room: TSubscriptionModel;
|
||||||
private name: TextInput | null | undefined;
|
private name: TextInput | null | undefined;
|
||||||
private description: TextInput | null | undefined;
|
private description: TextInput | null | undefined;
|
||||||
|
@ -123,12 +121,6 @@ class RoomInfoEditView extends React.Component<IRoomInfoEditViewProps, IRoomInfo
|
||||||
this.loadRoom();
|
this.loadRoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
if (this.querySubscription && this.querySubscription.unsubscribe) {
|
|
||||||
this.querySubscription.unsubscribe();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
loadRoom = async () => {
|
loadRoom = async () => {
|
||||||
const {
|
const {
|
||||||
route,
|
route,
|
||||||
|
@ -147,12 +139,8 @@ class RoomInfoEditView extends React.Component<IRoomInfoEditViewProps, IRoomInfo
|
||||||
try {
|
try {
|
||||||
const db = database.active;
|
const db = database.active;
|
||||||
const sub = await db.get('subscriptions').find(rid);
|
const sub = await db.get('subscriptions').find(rid);
|
||||||
const observable = sub.observe();
|
this.room = sub;
|
||||||
|
this.init(this.room);
|
||||||
this.querySubscription = observable.subscribe(data => {
|
|
||||||
this.room = data;
|
|
||||||
this.init(this.room);
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await hasPermission(
|
const result = await hasPermission(
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue