diff --git a/app/lib/Navigation.js b/app/lib/Navigation.js index 34aba1769..01410aab8 100644 --- a/app/lib/Navigation.js +++ b/app/lib/Navigation.js @@ -16,10 +16,15 @@ function replace(name, params) { navigationRef.current?.dispatch(StackActions.replace(name, params)); } +function reset({ index, routes }) { + navigationRef.current?.dispatch(CommonActions.reset({ index, routes })); +} + export default { navigationRef, routeNameRef, navigate, back, - replace + replace, + reset }; diff --git a/app/utils/goRoom.js b/app/utils/goRoom.js index e9811e651..a4c9a452e 100644 --- a/app/utils/goRoom.js +++ b/app/utils/goRoom.js @@ -2,10 +2,35 @@ import Navigation from '../lib/Navigation'; import RocketChat from '../lib/rocketchat'; const navigate = ({ item, isMasterDetail, ...props }) => { - let navigationMethod = props.navigationMethod ?? Navigation.navigate; + const navigationMethod = props.navigationMethod ?? Navigation.navigate; if (isMasterDetail) { - navigationMethod = Navigation.replace; + return Navigation.reset({ + index: 0, + routes: [ + { + name: 'ChatsStackNavigator', + state: { + routes: [ + { + name: 'RoomView', + params: { + rid: item.rid, + name: RocketChat.getRoomTitle(item), + t: item.t, + prid: item.prid, + room: item, + visitor: item.visitor, + roomUserId: RocketChat.getUidDirectMessage(item), + ...props + } + } + ] + } + + } + ] + }); } navigationMethod('RoomView', {