Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const screenTracking = ({ getState }) => next => action => {
if (
action.type !== NavigationActions.NAVIGATE &&
action.type !== NavigationActions.BACK
) {
return next(action);
}
const currentScreen = getCurrentRouteName(getState().nav);
const result = next(action);
const nextScreen = getCurrentRouteName(getState().nav);
if (nextScreen !== currentScreen) {
try {
if (__DEV__ && console.tron) {
console.tron.log(`NAVIGATING ${currentScreen} to ${nextScreen}`);
}
// Example: Analytics.trackEvent('user_navigation', {currentScreen, nextScreen})
} catch (e) {
console.tron.log(e);
const screenTracking = ({ getState }) => next => (action) => {
if (
action.type !== NavigationActions.NAVIGATE &&
action.type !== NavigationActions.BACK
) {
return next(action)
}
const currentScreen = getCurrentRouteName(getState().nav)
const result = next(action)
const nextScreen = getCurrentRouteName(getState().nav)
if (nextScreen !== currentScreen) {
try {
console.tron.log(`NAVIGATING ${currentScreen} to ${nextScreen}`)
// Example: Analytics.trackEvent('user_navigation', {currentScreen, nextScreen})
} catch (e) {
console.tron.log(e)
}
}
const screenTracking = ({ getState }) => (next) => (action) => {
if (
action.type !== NavigationActions.NAVIGATE &&
action.type !== NavigationActions.BACK
) {
return next(action);
}
const currentScreen = getCurrentRouteName(getState().nav);
const result = next(action);
const nextScreen = getCurrentRouteName(getState().nav);
if (nextScreen !== currentScreen) {
try {
Reactotron.log(`NAVIGATING ${currentScreen} to ${nextScreen}`);
// Example: Analytics.trackEvent('user_navigation', {currentScreen, nextScreen})
} catch (e) {
Reactotron.log(e);
}
}
const getStateForActionWithoutDuplicates = (action, state) => {
if (action.type === NavigationActions.NAVIGATE) {
const previousRoute = getActiveRouteForState(StateUtils.back(state))
const currentRoute = getActiveRouteForState(state)
const nextRoute = action
if (
isDrawerRoute(currentRoute) &&
(
isEqualRoute(previousRoute, nextRoute) ||
areDuplicateRoots(state.routes, nextRoute.routeName)
)
) {
return StateUtils.back(state) // Close drawer
}
if (
isEqualRoute(currentRoute, nextRoute) ||
function navigate(navigatorType, routeName, params = {}, key) {
const navigator = navigators[navigatorType];
if (!navigator) {
return;
}
const payload = {
key,
params,
routeName,
type: NavigationActions.NAVIGATE,
};
navigator.dispatch(NavigationActions.navigate(payload));
}
const screenTracker = ({ getState }) => next => (action) => {
if (
action.type !== NavigationActions.NAVIGATE
&& action.type !== NavigationActions.BACK
) {
return next(action);
}
const currentScreen = getCurrentRouteName(getState().nav);
const result = next(action);
const nextScreen = getCurrentRouteName(getState().nav);
if (nextScreen !== currentScreen) {
tracker.trackScreenView(nextScreen);
}
return result;
};
RoomContainer.router.getStateForAction = (action, state) => {
if (action.type === NavigationActions.NAVIGATE && isSplited()) {
const { routeName, params } = action;
if (routeName === 'RoomActionsView') {
modalRef.dispatch(NavigationActions.navigate({ routeName, params }));
setState({ showModal: true });
return null;
}
if (routeName === 'AttachmentView') {
modalRef.dispatch(NavigationActions.navigate({ routeName, params }));
setState({ showModal: true });
return null;
}
}
if (action.type === 'Navigation/RESET' && isSplited()) {
const { params } = action.actions[action.index];
const routes = state.routes[state.index] && state.routes[state.index].params;
if (params && params.rid && routes && routes.rid && params.rid === routes.rid) {
function navigate(routeName, params) {
_navigator.dispatch(
NavigationActions.navigate({
type: NavigationActions.NAVIGATE,
routeName,
params,
})
);
}
) => (action: NavigationAction, state: NavigationState) => {
const { type } = action;
if (state && type === NavigationActions.NAVIGATE) {
const { routeName } = action;
if (routeName === state.routes[state.routes.length - 1].routeName) {
return state;
}
}
return getStateForAction(action, state);
};
const authRoutes = [
"MyOrderDrawer",
"Order",
"PayTypeDrawer",
"CouponDrawer",
"Credit",
"Manage_Card",
"UserInfoDrawer",
"Coupon",
"MyOrder",
"PayType",
"UserInfo",
"MonthTicket",
"MonthTicketDrawer"
];
if (state && action.type == NavigationActions.NAVIGATE) {
return (
authRoutes.indexOf(action.routeName) > -1 &&
store.getState().auth.username == null
);
} else {
return false;
}
}