From ea26108fc2d3ce259edcc4e3402cac19d75ad3c6 Mon Sep 17 00:00:00 2001 From: kresnaputra Date: Fri, 5 Feb 2021 23:32:38 +0800 Subject: [PATCH 1/3] [FIX] DM rooms show typing status from last group room --- app/views/RoomView/index.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index 38a39d97953..299c35dd981 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -155,20 +155,18 @@ class RoomView extends React.Component { this.list = React.createRef(); this.joinCode = React.createRef(); this.mounted = false; - if (this.rid) { - this.sub = new RoomClass(this.rid); - } + console.timeEnd(`${ this.constructor.name } init`); } componentDidMount() { + const { navigation } = this.props; this.mounted = true; this.offset = 0; this.didMountInteraction = InteractionManager.runAfterInteractions(() => { const { isAuthenticated } = this.props; this.setHeader(); if (this.rid) { - this.sub.subscribe(); if (isAuthenticated) { this.init(); } else { @@ -184,6 +182,15 @@ class RoomView extends React.Component { } EventEmitter.addEventListener('ROOM_REMOVED', this.handleRoomRemoved); console.timeEnd(`${ this.constructor.name } mount`); + + const unsubscribe = navigation.addListener('focus', () => { + if (this.rid) { + this.sub = new RoomClass(this.rid); + this.sub.subscribe(); + } + }); + + return unsubscribe; } shouldComponentUpdate(nextProps, nextState) { @@ -804,8 +811,10 @@ class RoomView extends React.Component { if (isMasterDetail) { navParam.showCloseModal = true; navigation.navigate('ModalStackNavigator', { screen: 'RoomInfoView', params: navParam }); + this.unsubscribe(); } else { navigation.navigate('RoomInfoView', navParam); + this.unsubscribe(); } } From 81233397ae60c7d5efff2f2ad02c35fd8caa565c Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 23 Feb 2021 13:54:57 -0300 Subject: [PATCH 2/3] Undo changes --- app/views/RoomView/index.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index 299c35dd981..38a39d97953 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -155,18 +155,20 @@ class RoomView extends React.Component { this.list = React.createRef(); this.joinCode = React.createRef(); this.mounted = false; - + if (this.rid) { + this.sub = new RoomClass(this.rid); + } console.timeEnd(`${ this.constructor.name } init`); } componentDidMount() { - const { navigation } = this.props; this.mounted = true; this.offset = 0; this.didMountInteraction = InteractionManager.runAfterInteractions(() => { const { isAuthenticated } = this.props; this.setHeader(); if (this.rid) { + this.sub.subscribe(); if (isAuthenticated) { this.init(); } else { @@ -182,15 +184,6 @@ class RoomView extends React.Component { } EventEmitter.addEventListener('ROOM_REMOVED', this.handleRoomRemoved); console.timeEnd(`${ this.constructor.name } mount`); - - const unsubscribe = navigation.addListener('focus', () => { - if (this.rid) { - this.sub = new RoomClass(this.rid); - this.sub.subscribe(); - } - }); - - return unsubscribe; } shouldComponentUpdate(nextProps, nextState) { @@ -811,10 +804,8 @@ class RoomView extends React.Component { if (isMasterDetail) { navParam.showCloseModal = true; navigation.navigate('ModalStackNavigator', { screen: 'RoomInfoView', params: navParam }); - this.unsubscribe(); } else { navigation.navigate('RoomInfoView', navParam); - this.unsubscribe(); } } From e656eb72c408424c9f1a4f941b62fb14790ca033 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 23 Feb 2021 13:56:09 -0300 Subject: [PATCH 3/3] Check if current typing is from focused room before dispatching to redux --- app/lib/methods/subscriptions/room.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/lib/methods/subscriptions/room.js b/app/lib/methods/subscriptions/room.js index 71ac3dfeee2..a6e4e34ad6d 100644 --- a/app/lib/methods/subscriptions/room.js +++ b/app/lib/methods/subscriptions/room.js @@ -90,6 +90,10 @@ export default class RoomSubscription { if (ev === 'typing') { const { user } = reduxStore.getState().login; const { UI_Use_Real_Name } = reduxStore.getState().settings; + const { rooms } = reduxStore.getState().room; + if (rooms[0] !== _rid) { + return; + } const [name, typing] = ddpMessage.fields.args; const key = UI_Use_Real_Name ? 'name' : 'username'; if (name !== user[key]) {