Skip to content

Commit

Permalink
fix(menuClose): expire nextViewOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Dec 1, 2014
1 parent e74de97 commit bba9e79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion js/angular/directive/menuClose.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ IonicModule
if (sideMenuCtrl) {
$ionicHistory.nextViewOptions({
historyRoot: true,
disableAnimate: true
disableAnimate: true,
expire: 300
});
sideMenuCtrl.close();
}
Expand Down
12 changes: 10 additions & 2 deletions js/angular/service/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ IonicModule
'$state',
'$location',
'$window',
'$timeout',
'$ionicViewSwitcher',
'$ionicNavViewDelegate',
function($rootScope, $state, $location, $window, $ionicViewSwitcher, $ionicNavViewDelegate) {
function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $ionicNavViewDelegate) {

// history actions while navigating views
var ACTION_INITIAL_VIEW = 'initialView';
Expand All @@ -40,7 +41,7 @@ function($rootScope, $state, $location, $window, $ionicViewSwitcher, $ionicNavVi
var DIRECTION_NONE = 'none';

var stateChangeCounter = 0;
var lastStateId, nextViewOptions, forcedNav;
var lastStateId, nextViewOptions, nextViewExpireTimer, forcedNav;

var viewHistory = {
histories: { root: { historyId: 'root', parentHistoryId: null, stack: [], cursor: -1 } },
Expand Down Expand Up @@ -364,6 +365,7 @@ function($rootScope, $state, $location, $window, $ionicViewSwitcher, $ionicNavVi
hist.stack.push(viewHistory.views[viewId]);
}

$timeout.cancel(nextViewExpireTimer);
if (nextViewOptions) {
if (nextViewOptions.disableAnimate) direction = DIRECTION_NONE;
if (nextViewOptions.disableBack) viewHistory.views[viewId].backViewId = null;
Expand Down Expand Up @@ -627,11 +629,17 @@ function($rootScope, $state, $location, $window, $ionicViewSwitcher, $ionicNavVi
*/
nextViewOptions: function(opts) {
if (arguments.length) {
$timeout.cancel(nextViewExpireTimer);
if (opts === null) {
nextViewOptions = opts;
} else {
nextViewOptions = nextViewOptions || {};
extend(nextViewOptions, opts);
if (nextViewOptions.expire) {
nextViewExpireTimer = $timeout(function(){
nextViewOptions = null;
}, nextViewOptions.expire);
}
}
}
return nextViewOptions;
Expand Down

1 comment on commit bba9e79

@vladipus
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was that really necessary? It seems kinda cheesy with that 300 ms magic number and stuff. This also breaks the Router's resolve functionality since it may delay the state transition considerably, far more than just 300 ms.
See this bug, please: #3027

Please sign in to comment.