From fc62e554ceda1269ff2091eecc18251fd450f76d Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sat, 4 Aug 2018 14:46:17 +0000 Subject: [PATCH] refactor: Move pm_with_uri to hash_util. --- frontend_tests/node_tests/narrow.js | 2 +- frontend_tests/node_tests/pm_list.js | 2 -- static/js/buddy_data.js | 2 +- static/js/hash_util.js | 5 +++++ static/js/narrow.js | 6 ------ static/js/pm_list.js | 2 +- static/js/popovers.js | 4 ++-- 7 files changed, 10 insertions(+), 13 deletions(-) diff --git a/frontend_tests/node_tests/narrow.js b/frontend_tests/node_tests/narrow.js index 3fc5398443..ac61910f69 100644 --- a/frontend_tests/node_tests/narrow.js +++ b/frontend_tests/node_tests/narrow.js @@ -61,7 +61,7 @@ run_test('uris', () => { people.add(ray); people.add(alice); - var uri = narrow.pm_with_uri(ray.email); + var uri = hash_util.pm_with_uri(ray.email); assert.equal(uri, '#narrow/pm-with/22-ray'); uri = narrow.huddle_with_uri("22,23"); diff --git a/frontend_tests/node_tests/pm_list.js b/frontend_tests/node_tests/pm_list.js index eb2ff1f477..c98f937901 100644 --- a/frontend_tests/node_tests/pm_list.js +++ b/frontend_tests/node_tests/pm_list.js @@ -15,8 +15,6 @@ set_global('popovers', { }); zrequire('hash_util'); -zrequire('hashchange'); -zrequire('narrow'); zrequire('Handlebars', 'handlebars'); zrequire('templates'); zrequire('people'); diff --git a/static/js/buddy_data.js b/static/js/buddy_data.js index a6b812e02e..6a623be36b 100644 --- a/static/js/buddy_data.js +++ b/static/js/buddy_data.js @@ -101,7 +101,7 @@ exports.info_for = function (user_id) { var person = people.get_person_from_user_id(user_id); return { - href: narrow.pm_with_uri(person.email), + href: hash_util.pm_with_uri(person.email), name: person.full_name, user_id: user_id, num_unread: get_num_unread(user_id), diff --git a/static/js/hash_util.js b/static/js/hash_util.js index b0d4f8859f..66567730ba 100644 --- a/static/js/hash_util.js +++ b/static/js/hash_util.js @@ -86,6 +86,11 @@ exports.operators_to_hash = function (operators) { return hash; }; +exports.pm_with_uri = function (reply_to) { + return exports.operators_to_hash([ + {operator: 'pm-with', operand: reply_to}, + ]); +}; return exports; diff --git a/static/js/narrow.js b/static/js/narrow.js index 44a1700396..7aa97c6fcb 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -767,12 +767,6 @@ exports.hide_empty_narrow_message = function () { $(".empty_feed_notice").hide(); }; -exports.pm_with_uri = function (reply_to) { - return hash_util.operators_to_hash([ - {operator: 'pm-with', operand: reply_to}, - ]); -}; - exports.huddle_with_uri = function (user_ids_string) { // This method is convenient is convenient for callers // that have already converted emails to a comma-delimited diff --git a/static/js/pm_list.js b/static/js/pm_list.js index db45979bdb..553bc315fd 100644 --- a/static/js/pm_list.js +++ b/static/js/pm_list.js @@ -111,7 +111,7 @@ exports._build_private_messages_list = function (active_conversation, max_privat unread: num_unread, is_zero: num_unread === 0, zoom_out_hide: !always_visible, - url: narrow.pm_with_uri(reply_to), + url: hash_util.pm_with_uri(reply_to), }; display_messages.push(display_message); }); diff --git a/static/js/popovers.js b/static/js/popovers.js index b3bfee0208..bcbaf83d92 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -144,7 +144,7 @@ function show_user_info_popover(element, user, message) { user_time: people.get_user_time(user.user_id), presence_status: presence.get_status(user.user_id), user_last_seen_time_status: user_last_seen_time_status(user.user_id), - pm_with_uri: narrow.pm_with_uri(user.email), + pm_with_uri: hash_util.pm_with_uri(user.email), sent_by_uri: narrow.by_sender_uri(user.email), narrowed: narrow_state.active(), private_message_class: "respond_personal_button", @@ -701,7 +701,7 @@ exports.register_click_handlers = function () { user_time: people.get_user_time(user_id), presence_status: presence.get_status(user_id), user_last_seen_time_status: user_last_seen_time_status(user_id), - pm_with_uri: narrow.pm_with_uri(user_email), + pm_with_uri: hash_util.pm_with_uri(user_email), sent_by_uri: narrow.by_sender_uri(user_email), private_message_class: "compose_private_message", is_active: people.is_active_user_for_popover(user_id),