Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,39 +126,31 @@ class Actions {
if (!this.currentRouter){
throw new Error("No current router is set");
}
if (num > 1){
for (let i=0;i<num;i++){
if (!this.pop()){
return false;
}
}
return true;
} else {
let router: BaseRouter = this.currentRouter;
debug("Pop, router="+router.name+" stack length:"+router.stack.length);
debug("Current route="+router.currentRoute.name+" type="+router.currentRoute.type);
while (router.stack.length <= 1 || router.currentRoute.type === 'switch'){
if (router.parentRoute) {
router = router.parentRoute.parent;
debug("Switching to parent router="+router.name);
} else {
break;
}

let router: BaseRouter = this.currentRouter;
debug("Pop, router="+router.name+" stack length:"+router.stack.length);
debug("Current route="+router.currentRoute.name+" type="+router.currentRoute.type);
while (router.stack.length <= 1 || router.currentRoute.type === 'switch'){
if (router.parentRoute) {
router = router.parentRoute.parent;
debug("Switching to parent router="+router.name);
} else {
break;
}
}
if (router.delegate.props && router.delegate.props.dispatch){
router.delegate.props.dispatch({...props, type: BEFORE_POP, route:router.currentRoute, name:router.currentRoute.name})
}
if (router.pop(num, props)){
this.currentRouter = router;
if (router.delegate.props && router.delegate.props.dispatch){
router.delegate.props.dispatch({...props, type: BEFORE_POP, route:router.currentRoute, name:router.currentRoute.name})
}
if (router.pop(1, props)){
this.currentRouter = router;
if (router.delegate.props && router.delegate.props.dispatch){
router.delegate.props.dispatch({...props, type: AFTER_POP, route:router.currentRoute, name:router.currentRoute.name})
}
return true;
} else {
return false;
router.delegate.props.dispatch({...props, type: AFTER_POP, route:router.currentRoute, name:router.currentRoute.name})
}

return true;
} else {
return false;
}

}
}
const actions = new Actions();
Expand Down
7 changes: 6 additions & 1 deletion ExRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,12 @@ export default class ExRouter extends React.Component {
return false;
}
}
this.refs.nav.pop();

if (num === 1) {
this.refs.nav.pop();
} else {
this.refs.nav.popBack(num);
}
return true;
}

Expand Down