From e52739e3053e165895783889a9e11760a37214f4 Mon Sep 17 00:00:00 2001
From: Diego Mello <diegolmello@gmail.com>
Date: Thu, 20 Jun 2019 16:02:50 -0300
Subject: [PATCH] [FIX] Join discussion (#1000)

---
 app/lib/rocketchat.js       |  5 ++++-
 app/views/RoomView/index.js | 10 ++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js
index 21ad4b1e4..a0118f5e7 100644
--- a/app/lib/rocketchat.js
+++ b/app/lib/rocketchat.js
@@ -447,9 +447,12 @@ const RocketChat = {
 		// RC 0.59.0
 		return this.sdk.post('im.create', { username });
 	},
-	joinRoom(roomId) {
+	joinRoom(roomId, type) {
 		// TODO: join code
 		// RC 0.48.0
+		if (type === 'p') {
+			return this.sdk.methodCall('joinRoom', roomId);
+		}
 		return this.sdk.post('channels.join', { roomId });
 	},
 	sendFileMessage,
diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js
index 6ed1b0445..2dc7f4fdc 100644
--- a/app/views/RoomView/index.js
+++ b/app/views/RoomView/index.js
@@ -437,12 +437,10 @@ export default class RoomView extends React.Component {
 
 	joinRoom = async() => {
 		try {
-			const result = await RocketChat.joinRoom(this.rid);
-			if (result.success) {
-				this.internalSetState({
-					joined: true
-				});
-			}
+			await RocketChat.joinRoom(this.rid, this.t);
+			this.internalSetState({
+				joined: true
+			});
 		} catch (e) {
 			log('err_join_room', e);
 		}
-- 
GitLab