mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 05:53:43 +00:00
Use data-user-ids-string in Private Messages sidebar.
This commit also changed message_store.recent_private_messages to use user_ids_string instead of reply_to.
This commit is contained in:
@@ -5,6 +5,7 @@ add_dependencies({
|
|||||||
templates: 'js/templates',
|
templates: 'js/templates',
|
||||||
muting: 'js/muting',
|
muting: 'js/muting',
|
||||||
narrow: 'js/narrow',
|
narrow: 'js/narrow',
|
||||||
|
people: 'js/people',
|
||||||
stream_color: 'js/stream_color',
|
stream_color: 'js/stream_color',
|
||||||
stream_data: 'js/stream_data',
|
stream_data: 'js/stream_data',
|
||||||
subs: 'js/subs',
|
subs: 'js/subs',
|
||||||
@@ -33,15 +34,27 @@ global.compile_template('sidebar_private_message_list');
|
|||||||
global.compile_template('stream_sidebar_row');
|
global.compile_template('stream_sidebar_row');
|
||||||
global.compile_template('stream_privacy');
|
global.compile_template('stream_privacy');
|
||||||
|
|
||||||
|
var alice = {
|
||||||
|
email: 'alice@zulip.com',
|
||||||
|
user_id: 101,
|
||||||
|
full_name: 'Alice'
|
||||||
|
};
|
||||||
|
var bob = {
|
||||||
|
email: 'bob@zulip.com',
|
||||||
|
user_id: 102,
|
||||||
|
full_name: 'Bob'
|
||||||
|
};
|
||||||
|
global.people.add_in_realm(alice);
|
||||||
|
global.people.add_in_realm(bob);
|
||||||
|
|
||||||
(function test_build_private_messages_list() {
|
(function test_build_private_messages_list() {
|
||||||
var reply_tos = "alice@zulip.com,bob@zulip.com";
|
var active_conversation = "alice@zulip.com,bob@zulip.com";
|
||||||
var active_conversation = "Alice, Bob";
|
|
||||||
var max_conversations = 5;
|
var max_conversations = 5;
|
||||||
|
|
||||||
|
|
||||||
var conversations = {reply_to: reply_tos,
|
var conversations = {user_ids_string: '101,102',
|
||||||
display_reply_to: active_conversation,
|
display_reply_to: active_conversation,
|
||||||
timestamp: 0 };
|
timestamp: 0 };
|
||||||
global.message_store.recent_private_messages.push(conversations);
|
global.message_store.recent_private_messages.push(conversations);
|
||||||
|
|
||||||
global.unread.num_unread_for_person = function () {
|
global.unread.num_unread_for_person = function () {
|
||||||
|
|||||||
@@ -42,13 +42,20 @@ exports.get_private_message_recipient = function (message, attr, fallback_attr)
|
|||||||
exports.process_message_for_recent_private_messages = function process_message_for_recent_private_messages(message, remove_message) {
|
exports.process_message_for_recent_private_messages = function process_message_for_recent_private_messages(message, remove_message) {
|
||||||
var current_timestamp = 0;
|
var current_timestamp = 0;
|
||||||
|
|
||||||
|
var user_ids_string = people.emails_strings_to_user_ids_string(message.reply_to);
|
||||||
|
|
||||||
|
if (!user_ids_string) {
|
||||||
|
blueslip.warn('Unknown reply_to in message: ' + user_ids_string);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If this conversation is already tracked, we'll replace with new timestamp,
|
// If this conversation is already tracked, we'll replace with new timestamp,
|
||||||
// so remove it from the current list.
|
// so remove it from the current list.
|
||||||
exports.recent_private_messages = _.filter(exports.recent_private_messages, function (recent_pm) {
|
exports.recent_private_messages = _.filter(exports.recent_private_messages, function (recent_pm) {
|
||||||
return recent_pm.reply_to !== message.reply_to;
|
return recent_pm.user_ids_string !== user_ids_string;
|
||||||
});
|
});
|
||||||
|
|
||||||
var new_conversation = {reply_to: message.reply_to,
|
var new_conversation = {user_ids_string: user_ids_string,
|
||||||
display_reply_to: message.display_reply_to,
|
display_reply_to: message.display_reply_to,
|
||||||
timestamp: Math.max(message.timestamp, current_timestamp)};
|
timestamp: Math.max(message.timestamp, current_timestamp)};
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,17 @@ function set_count(type, name, count) {
|
|||||||
|
|
||||||
exports.get_conversation_li = function (conversation) {
|
exports.get_conversation_li = function (conversation) {
|
||||||
// conversation is something like "foo@example.com,bar@example.com"
|
// conversation is something like "foo@example.com,bar@example.com"
|
||||||
|
var user_ids_string = people.emails_strings_to_user_ids_string(conversation);
|
||||||
|
if (!user_ids_string) {
|
||||||
|
blueslip.warn('Unknown conversation: ' + conversation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return exports.get_li_for_user_ids_string(user_ids_string);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.get_li_for_user_ids_string = function (user_ids_string) {
|
||||||
var pm_li = get_filter_li();
|
var pm_li = get_filter_li();
|
||||||
var convo_li = pm_li.find("li[data-name='" + conversation + "']");
|
var convo_li = pm_li.find("li[data-user-ids-string='" + user_ids_string + "']");
|
||||||
return convo_li;
|
return convo_li;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,13 +74,20 @@ exports._build_private_messages_list = function (active_conversation, max_privat
|
|||||||
var display_messages = [];
|
var display_messages = [];
|
||||||
var hiding_messages = false;
|
var hiding_messages = false;
|
||||||
|
|
||||||
|
// SHIM
|
||||||
|
if (active_conversation) {
|
||||||
|
active_conversation = people.emails_strings_to_user_ids_string(active_conversation);
|
||||||
|
}
|
||||||
|
|
||||||
_.each(private_messages, function (private_message_obj, idx) {
|
_.each(private_messages, function (private_message_obj, idx) {
|
||||||
var recipients_string = private_message_obj.display_reply_to;
|
var recipients_string = private_message_obj.display_reply_to;
|
||||||
var replies_to = private_message_obj.reply_to;
|
var user_ids_string = private_message_obj.user_ids_string;
|
||||||
var num_unread = unread.num_unread_for_person(private_message_obj.reply_to);
|
var reply_to = people.user_ids_string_to_emails_string(user_ids_string);
|
||||||
|
|
||||||
|
var num_unread = unread.num_unread_for_person(reply_to);
|
||||||
|
|
||||||
var always_visible = (idx < max_private_messages) || (num_unread > 0)
|
var always_visible = (idx < max_private_messages) || (num_unread > 0)
|
||||||
|| (replies_to === active_conversation);
|
|| (user_ids_string === active_conversation);
|
||||||
|
|
||||||
if (!always_visible) {
|
if (!always_visible) {
|
||||||
hiding_messages = true;
|
hiding_messages = true;
|
||||||
@@ -79,11 +95,11 @@ exports._build_private_messages_list = function (active_conversation, max_privat
|
|||||||
|
|
||||||
var display_message = {
|
var display_message = {
|
||||||
recipients: recipients_string,
|
recipients: recipients_string,
|
||||||
reply_to: replies_to,
|
user_ids_string: user_ids_string,
|
||||||
unread: num_unread,
|
unread: num_unread,
|
||||||
is_zero: num_unread === 0,
|
is_zero: num_unread === 0,
|
||||||
zoom_out_hide: !always_visible,
|
zoom_out_hide: !always_visible,
|
||||||
url: narrow.pm_with_uri(private_message_obj.reply_to)
|
url: narrow.pm_with_uri(reply_to)
|
||||||
};
|
};
|
||||||
display_messages.push(display_message);
|
display_messages.push(display_message);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<ul class='expanded_private_messages' data-name='private'>
|
<ul class='expanded_private_messages' data-name='private'>
|
||||||
{{#each messages}}
|
{{#each messages}}
|
||||||
<li class='{{#if is_zero}}zero-subject-unreads{{/if}} {{#if zoom_out_hide}}zoom-out-hide{{/if}} expanded_private_message' data-name='{{reply_to}}'>
|
<li class='{{#if is_zero}}zero-subject-unreads{{/if}} {{#if zoom_out_hide}}zoom-out-hide{{/if}} expanded_private_message' data-user-ids-string='{{user_ids_string}}'>
|
||||||
<span class='pm-box'>
|
<span class='pm-box'>
|
||||||
<a href='{{url}}' class="conversation-partners">
|
<a href='{{url}}' class="conversation-partners">
|
||||||
{{recipients}}
|
{{recipients}}
|
||||||
|
|||||||
Reference in New Issue
Block a user