-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] NewMessageView Press Item should open DM
- Loading branch information
1 parent
0009e7f
commit 5700518
Showing
3 changed files
with
50 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Navigation from '../lib/Navigation'; | ||
import RocketChat from '../lib/rocketchat'; | ||
|
||
const navigate = (item) => { | ||
Navigation.navigate('RoomView', { | ||
rid: item.rid, | ||
name: RocketChat.getRoomTitle(item), | ||
t: item.t, | ||
prid: item.prid, | ||
room: item, | ||
search: item.search, | ||
visitor: item.visitor, | ||
roomUserId: RocketChat.getUidDirectMessage(item) | ||
}); | ||
}; | ||
|
||
export const goRoom = async(item = {}) => { | ||
if (!item.search) { | ||
return navigate(item); | ||
} | ||
if (item.t === 'd') { | ||
// if user is using the search we need first to join/create room | ||
try { | ||
const { username } = item; | ||
const result = await RocketChat.createDirectMessage(username); | ||
if (result.success) { | ||
return navigate({ | ||
rid: result.room._id, | ||
name: username, | ||
t: 'd' | ||
}); | ||
} | ||
} catch { | ||
// Do nothing | ||
} | ||
} else { | ||
return navigate(item); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters