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.

subs: Use hash_util to check if user is in "#streams/new".

Aman Agrawalb180c245b461
diff --git a/frontend_tests/node_tests/hash_util.js b/frontend_tests/node_tests/hash_util.js
index 4f82dc47f87..f046f843c2e 100644
--- a/frontend_tests/node_tests/hash_util.js
+++ b/frontend_tests/node_tests/hash_util.js
@@ -128,6 +128,14 @@ run_test("test_active_stream", () => {
assert.equal(hash_util.active_stream(), undefined);
});
+run_test("test_is_create_new_stream_narrow", () => {
+ location.hash = "#streams/new";
+ assert.equal(hash_util.is_create_new_stream_narrow(), true);
+
+ location.hash = "#some/random/hash";
+ assert.equal(hash_util.is_create_new_stream_narrow(), false);
+});
+
run_test("test_parse_narrow", () => {
assert.deepEqual(hash_util.parse_narrow(["narrow", "stream", "99-frontend"]), [
{negated: false, operator: "stream", operand: "frontend"},
diff --git a/static/js/hash_util.js b/static/js/hash_util.js
index d880eb9c207..dabe21a5814 100644
--- a/static/js/hash_util.js
+++ b/static/js/hash_util.js
@@ -266,3 +266,7 @@ export function active_stream() {
return undefined;
}
+
+export function is_create_new_stream_narrow() {
+ return window.location.hash === "#streams/new";
+}
diff --git a/static/js/subs.js b/static/js/subs.js
index 070b75e883b..23bdb7d9aca 100644
--- a/static/js/subs.js
+++ b/static/js/subs.js
@@ -754,7 +754,7 @@ export function launch(section) {
export function switch_rows(event) {
const active_data = get_active_data();
let switch_row;
- if (window.location.hash === "#streams/new") {
+ if (hash_util.is_create_new_stream_narrow()) {
// Prevent switching stream rows when creating a new stream
return false;
} else if (!active_data.id || active_data.row.hasClass("notdisplayed")) {