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