Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

recent-topics: Update hash for view to be "#recent".

Lauryn Menarde66f125ee6cf
diff --git a/frontend_tests/node_tests/hashchange.js b/frontend_tests/node_tests/hashchange.js
index 1dbcbe891eb..1c5b367ad53 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 4bebf5a98cc..dcf49bb6c51 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 29b397ac878..75de9050018 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 725e60cdb23..be0a6398596 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 7c8710f0bff..dfbbd98a7b3 100644
--- a/static/templates/bookend.hbs
+++ b/static/templates/bookend.hbs
@@ -2,7 +2,7 @@
<div class="{{#if is_trailing_bookend}}trailing_bookend {{/if}}bookend sub-unsub-message">
{{#if is_spectator}}
<span class="recent-topics-link">
- <a href="#recent_topics">{{t "Browse recent conversations" }}</a>
+ <a href="#recent">{{t "Browse recent conversations" }}</a>
</span>
{{else}}
<span class="stream-status">
diff --git a/static/templates/left_sidebar.hbs b/static/templates/left_sidebar.hbs
index a02e5295f7b..20ba8422658 100644
--- a/static/templates/left_sidebar.hbs
+++ b/static/templates/left_sidebar.hbs
@@ -14,7 +14,7 @@
<span class="arrow all-messages-sidebar-menu-icon hidden-for-spectators"><i class="zulip-icon zulip-icon-ellipsis-v-solid" aria-hidden="true"></i></span>
</li>
<li class="top_left_recent_topics top_left_row" title="{{t 'Recent conversations' }} (t)">
- <a href="#recent_topics">
+ <a href="#recent">
<span class="filter-icon">
<i class="fa fa-clock-o" aria-hidden="true"></i>
</span>
diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.py
index 323f2d92549..acc8b31df5d 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 6dd391811a2..856f28662c0 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)