hashchange: Show default view when the hash is unknown.

Fixes #18870.
This commit is contained in:
Riken Shah
2021-06-19 04:58:15 +00:00
committed by Tim Abbott
parent 5e53563016
commit 0e65225d06
2 changed files with 19 additions and 2 deletions

View File

@@ -170,14 +170,29 @@ run_test("hash_interactions", ({override}) => {
window_stub = $.create("window-stub"); window_stub = $.create("window-stub");
page_params.default_view = "recent_topics"; page_params.default_view = "recent_topics";
override(recent_topics_ui, "show", () => {});
override(recent_topics_util, "is_visible", () => false); override(recent_topics_util, "is_visible", () => false);
const helper = test_helper({override, change_tab: true}); const helper = test_helper({override, change_tab: true});
window.location.hash = "#all_messages"; let recent_topics_ui_shown = false;
override(recent_topics_ui, "show", () => {
recent_topics_ui_shown = true;
});
window.location.hash = "#unknown_hash";
browser_history.clear_for_testing(); browser_history.clear_for_testing();
hashchange.initialize(); hashchange.initialize();
// If it's an unknown hash it should show the default view.
assert.equal(recent_topics_ui_shown, true);
helper.assert_events([
[overlays, "close_for_hash_change"],
[message_viewport, "stop_auto_scrolling"],
]);
override(recent_topics_ui, "show", () => {});
window.location.hash = "#all_messages";
helper.clear_events();
window_stub.trigger("hashchange");
helper.assert_events([ helper.assert_events([
[overlays, "close_for_hash_change"], [overlays, "close_for_hash_change"],
[message_viewport, "stop_auto_scrolling"], [message_viewport, "stop_auto_scrolling"],

View File

@@ -179,6 +179,8 @@ function do_hashchange_normal(from_reload) {
case "#about-zulip": case "#about-zulip":
blueslip.error("overlay logic skipped for: " + hash); blueslip.error("overlay logic skipped for: " + hash);
break; break;
default:
show_default_view();
} }
return false; return false;
} }