mirror of https://github.com/zulip/zulip.git
Show correct avatar for desktop notifications.
This updates desktop notifications to use avatar_url from the server (in case users have uploaded their own avatar). It also removes the unneeded stamp parameter from the URL, and it unifies URL handling with message_list. (imported from commit 6bb43a25c01cc3d26f30fc167780a477d1c5d023)
This commit is contained in:
parent
67ac671b74
commit
943a29dc34
|
@ -327,9 +327,7 @@ MessageList.prototype = {
|
||||||
|
|
||||||
message.dom_id = table_name + message.id;
|
message.dom_id = table_name + message.id;
|
||||||
|
|
||||||
if (message.sender_email === page_params.email) {
|
message.small_avatar_url = ui.small_avatar_url(message);
|
||||||
message.stamp = ui.get_gravatar_stamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.is_stream) {
|
if (message.is_stream) {
|
||||||
message.background_color = subs.get_color(message.stream);
|
message.background_color = subs.get_color(message.stream);
|
||||||
|
|
|
@ -107,11 +107,6 @@ exports.window_has_focus = function () {
|
||||||
return window_has_focus;
|
return window_has_focus;
|
||||||
};
|
};
|
||||||
|
|
||||||
function gravatar_url(message) {
|
|
||||||
return "https://secure.gravatar.com/avatar/" + message.gravatar_hash +
|
|
||||||
"?d=identicon&s=30?stamp=" + ui.get_gravatar_stamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
function process_desktop_notification(message) {
|
function process_desktop_notification(message) {
|
||||||
var i, notification_object, key;
|
var i, notification_object, key;
|
||||||
var title = message.sender_full_name;
|
var title = message.sender_full_name;
|
||||||
|
@ -166,9 +161,10 @@ function process_desktop_notification(message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.bridge === undefined) {
|
if (window.bridge === undefined) {
|
||||||
|
var icon_url = ui.small_avatar_url(message);
|
||||||
notice_memory[key] = {
|
notice_memory[key] = {
|
||||||
obj: window.webkitNotifications.createNotification(
|
obj: window.webkitNotifications.createNotification(
|
||||||
gravatar_url(message), title, content),
|
icon_url, title, content),
|
||||||
msg_count: msg_count
|
msg_count: msg_count
|
||||||
};
|
};
|
||||||
notification_object = notice_memory[key].obj;
|
notification_object = notice_memory[key].obj;
|
||||||
|
|
|
@ -607,8 +607,21 @@ function poll_for_gravatar_update(start_time, url) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.get_gravatar_stamp = function () {
|
exports.small_avatar_url = function (message) {
|
||||||
return gravatar_stamp;
|
// Try to call this function in all places where we need size-30
|
||||||
|
// quality gravatar images, so that the browser can help
|
||||||
|
// us avoid unnecessary network trips. (For user-uploaded avatars,
|
||||||
|
// the s=30 parameter is essentially ignored, but it's harmless.)
|
||||||
|
//
|
||||||
|
if (message.avatar_url) {
|
||||||
|
var url = message.avatar_url + "&s=30";
|
||||||
|
if (message.sender_email === page_params.email) {
|
||||||
|
url += "&stamp=" + gravatar_stamp;
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.wait_for_gravatar = function () {
|
exports.wait_for_gravatar = function () {
|
||||||
|
|
|
@ -58,8 +58,9 @@
|
||||||
<div class="message_top_line">
|
<div class="message_top_line">
|
||||||
{{#include_sender}}
|
{{#include_sender}}
|
||||||
<span class="message_sender actions_hover">
|
<span class="message_sender actions_hover">
|
||||||
|
{{! See ../js/notifications.js for another user of avatar_url. }}
|
||||||
<div class="inline_profile_picture"
|
<div class="inline_profile_picture"
|
||||||
style="background-image: url('{{avatar_url}}&s=30&stamp={{stamp}}');"/>
|
style="background-image: url('{{small_avatar_url}}');"/>
|
||||||
<span class="sender_name">{{sender_full_name}}</span>
|
<span class="sender_name">{{sender_full_name}}</span>
|
||||||
</span>
|
</span>
|
||||||
{{/include_sender}}
|
{{/include_sender}}
|
||||||
|
|
Loading…
Reference in New Issue