mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 03:11:54 +00:00
refactor: Have pm_conversations take user_ids.
Instead of having our callers pass in a possibly non-canonical version of a user_ids_string, just have them pass in a list. The next commit will canonicalize the sort.
This commit is contained in:
@@ -54,9 +54,7 @@ exports.process_message_for_recent_private_messages = function (message) {
|
||||
pm_conversations.set_partner(user_id);
|
||||
});
|
||||
|
||||
const user_ids_string = user_ids.join(',');
|
||||
|
||||
pm_conversations.recent.insert(user_ids_string, message.id);
|
||||
pm_conversations.recent.insert(user_ids, message.id);
|
||||
};
|
||||
|
||||
exports.set_message_booleans = function (message) {
|
||||
|
||||
@@ -18,13 +18,12 @@ exports.recent = (function () {
|
||||
const recent_message_ids = new Dict({fold_case: true}); // key is user_ids_string
|
||||
const recent_private_messages = [];
|
||||
|
||||
self.insert = function (user_ids_string, message_id) {
|
||||
if (user_ids_string === '') {
|
||||
// The API uses '' for self-PMs; convert it to the string
|
||||
// containing the current user's ID, which is the format
|
||||
// the webapp expects.
|
||||
user_ids_string = people.my_current_user_id().toString();
|
||||
self.insert = function (user_ids, message_id) {
|
||||
if (user_ids.length === 0) {
|
||||
// The server sends [] for self-PMs.
|
||||
user_ids = [people.my_current_user_id()];
|
||||
}
|
||||
const user_ids_string = user_ids.join(',');
|
||||
let conversation = recent_message_ids.get(user_ids_string);
|
||||
|
||||
if (conversation === undefined) {
|
||||
@@ -71,8 +70,7 @@ exports.recent = (function () {
|
||||
|
||||
self.initialize = function () {
|
||||
_.each(page_params.recent_private_conversations, function (conversation) {
|
||||
const user_ids_string = conversation.user_ids.join(",");
|
||||
self.insert(user_ids_string, conversation.max_message_id);
|
||||
self.insert(conversation.user_ids, conversation.max_message_id);
|
||||
});
|
||||
delete page_params.recent_private_messages;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user