mirror of
https://github.com/zulip/zulip.git
synced 2026-07-06 21:18:58 +08:00
narrow: Rename save_narrow.
This commit is contained in:
parent
625b07c010
commit
cd41e5f4fa
@ -86,11 +86,11 @@ export function changehash(newhash, trigger) {
|
||||
browser_history.set_hash(newhash);
|
||||
}
|
||||
|
||||
export function save_narrow(terms, trigger) {
|
||||
export function update_hash_to_match_filter(filter, trigger) {
|
||||
if (browser_history.state.changing_hash && trigger !== "retarget message location") {
|
||||
return;
|
||||
}
|
||||
const new_hash = hash_util.search_terms_to_hash(terms);
|
||||
const new_hash = hash_util.search_terms_to_hash(filter.terms());
|
||||
changehash(new_hash, trigger);
|
||||
}
|
||||
|
||||
@ -477,7 +477,7 @@ export function activate(raw_terms, opts) {
|
||||
// bugs related to the URL fragment/hash being desynced from
|
||||
// mesasge_lists.current.
|
||||
if (opts.change_hash) {
|
||||
save_narrow(terms, opts.trigger);
|
||||
update_hash_to_match_filter(filter, opts.trigger);
|
||||
}
|
||||
|
||||
// Show the new set of messages. It is important to set message_lists.current to
|
||||
|
||||
@ -369,13 +369,13 @@ run_test("hash_interactions", ({override, override_rewire}) => {
|
||||
helper.assert_events([[ui_util, "blur_active_element"]]);
|
||||
});
|
||||
|
||||
run_test("save_narrow", ({override, override_rewire}) => {
|
||||
run_test("update_hash_to_match_filter", ({override, override_rewire}) => {
|
||||
const helper = test_helper({override, override_rewire});
|
||||
|
||||
let terms = [{operator: "is", operand: "dm"}];
|
||||
|
||||
blueslip.expect("error", "browser does not support pushState");
|
||||
narrow.save_narrow(terms);
|
||||
narrow.update_hash_to_match_filter(new Filter(terms));
|
||||
|
||||
helper.assert_events([[message_viewport, "stop_auto_scrolling"]]);
|
||||
assert.equal(window.location.hash, "#narrow/is/dm");
|
||||
@ -388,7 +388,7 @@ run_test("save_narrow", ({override, override_rewire}) => {
|
||||
terms = [{operator: "is", operand: "starred"}];
|
||||
|
||||
helper.clear_events();
|
||||
narrow.save_narrow(terms);
|
||||
narrow.update_hash_to_match_filter(new Filter(terms));
|
||||
helper.assert_events([[message_viewport, "stop_auto_scrolling"]]);
|
||||
assert.equal(url_pushed, "http://zulip.zulipdev.com/#narrow/is/starred");
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user