diff --git a/frontend_tests/node_tests/hashchange.js b/frontend_tests/node_tests/hashchange.js index 1dbcbe891e..1c5b367ad5 100644 --- a/frontend_tests/node_tests/hashchange.js +++ b/frontend_tests/node_tests/hashchange.js @@ -205,6 +205,19 @@ run_test("hash_interactions", ({override}) => { [floating_recipient_bar, "update"], ]); + // Test old "#recent_topics" hash redirects to "#recent". + recent_topics_ui_shown = false; + window.location.hash = "#recent_topics"; + + helper.clear_events(); + $window_stub.trigger("hashchange"); + assert.equal(recent_topics_ui_shown, true); + helper.assert_events([ + [overlays, "close_for_hash_change"], + [message_viewport, "stop_auto_scrolling"], + ]); + assert.equal(window.location.hash, "#recent"); + window.location.hash = "#narrow/stream/Denmark"; helper.clear_events(); diff --git a/static/js/hash_util.js b/static/js/hash_util.js index 4bebf5a98c..dcf49bb6c5 100644 --- a/static/js/hash_util.js +++ b/static/js/hash_util.js @@ -272,8 +272,13 @@ export function is_spectator_compatible(hash) { // This implementation should agree with the similar function in zerver/lib/narrow.py. const web_public_allowed_hashes = [ "", - "narrow", // full #narrow hash handled in narrow.is_spectator_compatible + // full #narrow hash handled in narrow.is_spectator_compatible + "narrow", + // TODO/compatibility: #recent_topics was renamed to #recent + // in 2022. We should support the old URL fragment at least + // until one cannot directly upgrade from Zulip 5.x. "recent_topics", + "recent", "keyboard-shortcuts", "message-formatting", "search-operators", diff --git a/static/js/hashchange.js b/static/js/hashchange.js index 29b397ac87..75de905001 100644 --- a/static/js/hashchange.js +++ b/static/js/hashchange.js @@ -181,6 +181,17 @@ function do_hashchange_normal(from_reload) { show_default_view(); break; case "#recent_topics": + // The URL for Recent Conversations was changed from + // #recent_topics to #recent in 2022. Because pre-change + // Welcome Bot messages included links to this URL, we + // need to support the "#recent_topics" hash as an alias + // for #recent permanently. We show the view and then + // replace the current URL hash in a way designed to hide + // this detail in the browser's forward/back session history. + recent_topics_ui.show(); + window.location.replace("#recent"); + break; + case "#recent": recent_topics_ui.show(); break; case "#all_messages": diff --git a/static/js/hotkey.js b/static/js/hotkey.js index 725e60cdb2..be0a639859 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -819,7 +819,7 @@ export function process_hotkey(e, hotkey) { narrow.narrow_to_next_pm_string(); return true; case "open_recent_topics": - browser_history.go_to_location("#recent_topics"); + browser_history.go_to_location("#recent"); return true; case "all_messages": browser_history.go_to_location("#all_messages"); diff --git a/static/templates/bookend.hbs b/static/templates/bookend.hbs index 7c8710f0bf..dfbbd98a7b 100644 --- a/static/templates/bookend.hbs +++ b/static/templates/bookend.hbs @@ -2,7 +2,7 @@
{{#if is_spectator}} - {{t "Browse recent conversations" }} + {{t "Browse recent conversations" }} {{else}} diff --git a/static/templates/left_sidebar.hbs b/static/templates/left_sidebar.hbs index a02e5295f7..20ba842265 100644 --- a/static/templates/left_sidebar.hbs +++ b/static/templates/left_sidebar.hbs @@ -14,7 +14,7 @@
  • - + diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.py index 323f2d9254..acc8b31df5 100644 --- a/zerver/lib/onboarding.py +++ b/zerver/lib/onboarding.py @@ -154,7 +154,7 @@ def select_welcome_bot_response(human_response_lower: str) -> str: ) + "\n\n", _( - "Check out [Recent conversations](#recent_topics) to see what's happening! " + "Check out [Recent conversations](#recent) to see what's happening! " 'You can return to this conversation by clicking "Private messages" in the upper left.' ), ] diff --git a/zerver/tests/test_tutorial.py b/zerver/tests/test_tutorial.py index 6dd391811a..856f28662c 100644 --- a/zerver/tests/test_tutorial.py +++ b/zerver/tests/test_tutorial.py @@ -98,7 +98,7 @@ class TutorialTests(ZulipTestCase): expected_response = ( "In Zulip, topics [tell you what a message is about](/help/streams-and-topics). " "They are light-weight subjects, very similar to the subject line of an email.\n\n" - "Check out [Recent conversations](#recent_topics) to see what's happening! " + "Check out [Recent conversations](#recent) to see what's happening! " 'You can return to this conversation by clicking "Private messages" in the upper left.' ) self.assertEqual(most_recent_message(user).content, expected_response)