hash_util: Remove dependency on narrow_state module.

We directly pass operators to remove dependency on narrow_state
module. This avoids a circular dependency of `filter` module
which is evident on the `/devtools/integrations/` page.
This commit is contained in:
Aman Agrawal
2021-11-29 06:48:17 +00:00
committed by Tim Abbott
parent c20f5a9866
commit 0fece515f2
3 changed files with 15 additions and 17 deletions

View File

@@ -1,7 +1,6 @@
import $ from "jquery";
import {$t_html} from "./i18n";
import * as narrow_state from "./narrow_state";
import * as people from "./people";
import * as stream_data from "./stream_data";
import * as ui_report from "./ui_report";
@@ -195,9 +194,7 @@ export function stream_edit_uri(sub) {
return hash;
}
export function search_public_streams_notice_url() {
// Computes the URL of the current narrow if streams:public were added.
const operators = narrow_state.filter().operators();
export function search_public_streams_notice_url(operators) {
const public_operator = {operator: "streams", operand: "public"};
return operators_to_hash([public_operator].concat(operators));
}

View File

@@ -84,7 +84,9 @@ export function show_end_of_results_notice() {
// It's a bit hacky to use the href, but
// !filter.includes_full_stream_history() implies streams:public
// wasn't already present.
const update_hash = hash_util.search_public_streams_notice_url();
// Computes the URL of the current narrow if streams:public were added.
const operators = narrow_state.filter().operators();
const update_hash = hash_util.search_public_streams_notice_url(operators);
$(".all-messages-search-caution a.search-shared-history").attr("href", update_hash);
}