diff --git a/frontend_tests/node_tests/message_list_view.js b/frontend_tests/node_tests/message_list_view.js index a2306d4c39..b32413260d 100644 --- a/frontend_tests/node_tests/message_list_view.js +++ b/frontend_tests/node_tests/message_list_view.js @@ -12,7 +12,7 @@ set_global('page_params', { }); set_global('home_msg_list', null); set_global('feature_flags', {twenty_four_hour_time: false}); -set_global('ui', {small_avatar_url: function () { return ''; }}); +set_global('people', {small_avatar_url: function () { return ''; }}); set_global('notifications', {speaking_at_me: function () {}}); set_global('unread', {message_unread: function () {}}); // timerender calls setInterval when imported diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js index 2041294d3a..092724abc1 100644 --- a/static/js/message_list_view.js +++ b/static/js/message_list_view.js @@ -223,7 +223,7 @@ MessageListView.prototype = { self._add_msg_timestring(message_container); - message_container.small_avatar_url = ui.small_avatar_url(message_container.msg); + message_container.small_avatar_url = people.small_avatar_url(message_container.msg); if (message_container.msg.stream !== undefined) { message_container.background_color = stream_data.get_color(message_container.msg.stream); diff --git a/static/js/notifications.js b/static/js/notifications.js index db4f2d35fd..a254cedccd 100644 --- a/static/js/notifications.js +++ b/static/js/notifications.js @@ -221,7 +221,7 @@ exports.window_has_focus = function () { function in_browser_notify(message, title, content, raw_operators, opts) { var notification_html = $(templates.render('notification', { - gravatar_url: ui.small_avatar_url(message), + gravatar_url: people.small_avatar_url(message), title: title, content: content, message_id: message.id, @@ -340,7 +340,7 @@ function process_notification(notification) { } if (window.bridge === undefined && notification.webkit_notify === true) { - var icon_url = ui.small_avatar_url(message); + var icon_url = people.small_avatar_url(message); notice_memory[key] = { obj: notifications_api.createNotification( icon_url, title, content, message.id), @@ -364,7 +364,7 @@ function process_notification(notification) { if (perm === 'granted') { notification_object = new Notification(title, { body: content, - iconUrl: ui.small_avatar_url(message), + iconUrl: people.small_avatar_url(message), tag: message.id, }); } else { diff --git a/static/js/people.js b/static/js/people.js index 73b80d9656..bb61a54fa9 100644 --- a/static/js/people.js +++ b/static/js/people.js @@ -120,6 +120,24 @@ exports.slug_to_emails = function (slug) { } }; +exports.small_avatar_url = function (message) { + // Try to call this function in all places where we need 25px + // avatar images, so that the browser can help + // us avoid unnecessary network trips. (For user-uploaded avatars, + // the s=25 parameter is essentially ignored, but it's harmless.) + // + // We actually request these at s=50, so that we look better + // on retina displays. + if (message.avatar_url) { + var url = message.avatar_url + "&s=50"; + if (message.sent_by_me) { + url += "&stamp=" + settings.avatar_stamp; + } + return url; + } + return ""; +}; + exports.realm_get = function realm_get(email) { return realm_people_dict.get(email); }; diff --git a/static/js/ui.js b/static/js/ui.js index caf801d36b..d06d066ec3 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -259,24 +259,6 @@ exports.show_failed_message_success = function (message_id) { }); }; -exports.small_avatar_url = function (message) { - // Try to call this function in all places where we need 25px - // avatar images, so that the browser can help - // us avoid unnecessary network trips. (For user-uploaded avatars, - // the s=25 parameter is essentially ignored, but it's harmless.) - // - // We actually request these at s=50, so that we look better - // on retina displays. - if (message.avatar_url) { - var url = message.avatar_url + "&s=50"; - if (message.sent_by_me) { - url += "&stamp=" + settings.avatar_stamp; - } - return url; - } - return ""; -}; - exports.lightbox = function (data) { switch (data.type) { case "photo":