Change the navigation aaction, instead of use replace, now it's using reset
This commit is contained in:
parent
6385daebb5
commit
ece46fe7b8
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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', {
|
||||
|
|
Loading…
Reference in New Issue