Compare commits

...

6 Commits

3 changed files with 34 additions and 5 deletions

View File

@ -16,10 +16,15 @@ function replace(name, params) {
navigationRef.current?.dispatch(StackActions.replace(name, params)); navigationRef.current?.dispatch(StackActions.replace(name, params));
} }
function reset({ index, routes }) {
navigationRef.current?.dispatch(CommonActions.reset({ index, routes }));
}
export default { export default {
navigationRef, navigationRef,
routeNameRef, routeNameRef,
navigate, navigate,
back, back,
replace replace,
reset
}; };

View File

@ -2,10 +2,35 @@ import Navigation from '../lib/Navigation';
import RocketChat from '../lib/rocketchat'; import RocketChat from '../lib/rocketchat';
const navigate = ({ item, isMasterDetail, ...props }) => { const navigate = ({ item, isMasterDetail, ...props }) => {
let navigationMethod = props.navigationMethod ?? Navigation.navigate; const navigationMethod = props.navigationMethod ?? Navigation.navigate;
if (isMasterDetail) { 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', { navigationMethod('RoomView', {

View File

@ -726,8 +726,7 @@ class RoomsListView extends React.Component {
goRoom = ({ item, isMasterDetail }) => { goRoom = ({ item, isMasterDetail }) => {
logEvent(events.RL_GO_ROOM); logEvent(events.RL_GO_ROOM);
const { item: currentItem } = this.state; const { item: currentItem } = this.state;
const { rooms } = this.props; if (currentItem?.rid === item.rid) {
if (currentItem?.rid === item.rid || rooms?.includes(item.rid)) {
return; return;
} }
// Only mark room as focused when in master detail layout // Only mark room as focused when in master detail layout