Immediately load_old_messages when the user arrives via a #narrow URL

(imported from commit 9705cbb70f9ce62ea5e362212ac91daf1b97ff13)
This commit is contained in:
Jeff Arnold 2012-12-20 19:04:27 -05:00
parent 8b56de22e0
commit ff57c9af59
1 changed files with 7 additions and 3 deletions

View File

@ -20,13 +20,14 @@ exports.changehash = function (newhash) {
}
};
// Returns true if this function performed a narrow
function hashchanged() {
// If window.location.hash changed because our app explicitly
// changed it, then we don't need to do anything.
// (This function only neds to jump into action if it changed
// because e.g. the back button was pressed by the user)
if (window.location.hash === expected_hash) {
return;
return false;
}
var hash = window.location.hash.split("/");
@ -35,7 +36,7 @@ function hashchanged() {
ui.change_tab_to("#home");
narrow.hashchanged(hash);
ui.update_floating_recipient_bar();
break;
return true;
case "":
case "#":
ui.change_tab_to("#home");
@ -49,11 +50,14 @@ function hashchanged() {
ui.change_tab_to("#settings");
break;
}
return false;
}
exports.initialize = function () {
window.onhashchange = hashchanged;
hashchanged();
if (hashchanged()) {
load_more_messages();
}
};
return exports;