fetchRoomUpdate

This commit is contained in:
Diego Mello 2022-12-06 17:10:12 -03:00
parent dbb9396042
commit 654feb719c
1 changed files with 8 additions and 5 deletions

View File

@ -205,6 +205,12 @@ interface IRoomViewState {
roomUserId?: string | null;
}
const fetchRoomUpdate = (room: any) =>
roomAttrsUpdate?.reduce((ret: any, attr) => {
ret[attr] = room[attr];
return ret;
}, {});
class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
private rid?: string;
private t?: string;
@ -265,7 +271,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
this.state = {
joined: true,
room,
roomUpdate: {},
roomUpdate: fetchRoomUpdate(room),
member: {},
lastOpen: null,
reactionsModalVisible: false,
@ -773,10 +779,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
observeRoom = (room: TSubscriptionModel) => {
const observable = room.observe();
this.subSubscription = observable.subscribe(changes => {
const roomUpdate = roomAttrsUpdate.reduce((ret: any, attr) => {
ret[attr] = changes[attr];
return ret;
}, {});
const roomUpdate = fetchRoomUpdate(changes);
if (this.mounted) {
this.internalSetState({ room: changes, roomUpdate, isOnHold: !!changes?.onHold });
} else {