From 2e65a795df604ddd684412d66cd36ce0170435bb Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Thu, 9 Apr 2020 02:20:57 -0300 Subject: [PATCH] [FIX] DM header blink (#2011) --- app/lib/methods/canOpenRoom.js | 11 +++++++++-- app/lib/rocketchat.js | 4 +++- app/sagas/deepLinking.js | 7 ++++++- app/views/RoomActionsView/index.js | 3 +-- app/views/RoomView/index.js | 4 ++-- app/views/RoomsListView/index.js | 5 +---- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/lib/methods/canOpenRoom.js b/app/lib/methods/canOpenRoom.js index ab79d1cd3..1578837aa 100644 --- a/app/lib/methods/canOpenRoom.js +++ b/app/lib/methods/canOpenRoom.js @@ -61,8 +61,15 @@ export default async function canOpenRoom({ rid, path }) { if (rid) { try { - await subsCollection.find(rid); - return { rid }; + const room = await subsCollection.find(rid); + return { + rid, + t: room.t, + name: room.name, + fname: room.fname, + prid: room.prid, + uids: room.uids + }; } catch (e) { // Do nothing } diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index f0dbf2489..ced274270 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -812,7 +812,9 @@ const RocketChat = { return this.sdk.get('rooms.info', { roomId }); }, - getUidDirectMessage(room, userId) { + getUidDirectMessage(room) { + const { id: userId } = reduxStore.getState().login.user; + // legacy method if (!room.uids && room.rid && room.t === 'd') { return room.rid.replace(userId, '').trim(); diff --git a/app/sagas/deepLinking.js b/app/sagas/deepLinking.js index 86467d3e2..a5427ea4f 100644 --- a/app/sagas/deepLinking.js +++ b/app/sagas/deepLinking.js @@ -34,7 +34,12 @@ const navigate = function* navigate({ params }) { const [type, name] = params.path.split('/'); if (room) { yield Navigation.navigate('RoomsListView'); - Navigation.navigate('RoomView', { name, t: roomTypes[type], ...room }); + Navigation.navigate('RoomView', { + name, + t: roomTypes[type], + roomUserId: RocketChat.getUidDirectMessage(room), + ...room + }); } } else { yield handleInviteLink({ params }); diff --git a/app/views/RoomActionsView/index.js b/app/views/RoomActionsView/index.js index 7fe261a84..21dc281f0 100644 --- a/app/views/RoomActionsView/index.js +++ b/app/views/RoomActionsView/index.js @@ -384,11 +384,10 @@ class RoomActionsView extends React.Component { updateRoomMember = async() => { const { room } = this.state; - const { user } = this.props; try { if (!RocketChat.isGroupChat(room)) { - const roomUserId = RocketChat.getUidDirectMessage(room, user.id); + const roomUserId = RocketChat.getUidDirectMessage(room); const result = await RocketChat.getUserInfo(roomUserId); if (result.success) { this.setState({ member: result.user }); diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index 9774e020b..ce34d46e8 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -390,10 +390,10 @@ class RoomView extends React.Component { const { t } = room; if (t === 'd' && !RocketChat.isGroupChat(room)) { - const { user, navigation } = this.props; + const { navigation } = this.props; try { - const roomUserId = RocketChat.getUidDirectMessage(room, user.id); + const roomUserId = RocketChat.getUidDirectMessage(room); navigation.setParams({ roomUserId }); diff --git a/app/views/RoomsListView/index.js b/app/views/RoomsListView/index.js index 61f41d43c..84aa0027b 100644 --- a/app/views/RoomsListView/index.js +++ b/app/views/RoomsListView/index.js @@ -531,10 +531,7 @@ class RoomsListView extends React.Component { getUserPresence = uid => RocketChat.getUserPresence(uid) - getUidDirectMessage = (room) => { - const { user: { id } } = this.props; - return RocketChat.getUidDirectMessage(room, id); - } + getUidDirectMessage = room => RocketChat.getUidDirectMessage(room); goRoom = (item) => { const { navigation } = this.props;