Example controller which attempts to change the hash before launch occurs and routing is called.

Code:



/**
* The main application controller. This is a good place to handle things like routes.
*/
Ext.define('app.controller.Root', {
extend: 'Ext.app.Controller',
requires: [
'Ext.util.History'
],


init: function() {
var history = Ext.util.History,
currentHash = history.getHash();
if (app.model.Member.isLoggedIn()) {

} else if (currentHash.indexOf('login') !== 0) {
// Both of these result in a double call because of the hashchange event.
// history.setHash('login/' + history.getHash());
this.getApplication().redirectTo('login/' + history.getHash());
}
}
});

Fix for Ext.util.History.handleStateChange

Code:



/**
* Fix for handleStateChange to chekcing if the currentToken is different than token before proceeding.
* Added a 'force' property as well so that handleStateChange could still continue if 'force' === true.
*/
Ext.define('app.util.History', {
override: 'Ext.util.History',
/**
* Handles when the hash in the URL has been updated. Will also fired the change event.
*
* @param {String} token The token that was changed to
* @private
*/
handleStateChange: function(token, force) {
if (this.currentToken !== token || force === true) {
this.callParent(arguments);
}
}
});