From ecdb2acf7924ba7ffe0f45c93fb073feab6ff75c Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 12 Apr 2013 12:47:41 -0400 Subject: [PATCH] Chop subjects to max of 5 regardless of timestamp of incoming messages (imported from commit a58cd25d9c129729e0eb42ae090f4c715b5e20fe) --- zephyr/static/js/zephyr.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 564b49b78f..092f42560e 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -467,6 +467,7 @@ var update_recent_subjects = $.debounce(100, ui.update_recent_subjects); function process_message_for_recent_subjects(message) { var current_timestamp = 0; + var max_subjects = 5; if (! recent_subjects.hasOwnProperty(message.display_recipient)) { recent_subjects[message.display_recipient] = []; @@ -482,10 +483,6 @@ function process_message_for_recent_subjects(message) { } var recents = recent_subjects[message.display_recipient]; - if (recents.length >= 5 && message.timestamp > recents[4].timestamp) { - recents = recents.slice(0, recents.length - 1); - } - recents.push({subject: message.subject, timestamp: Math.max(message.timestamp, current_timestamp)}); @@ -493,6 +490,8 @@ function process_message_for_recent_subjects(message) { return b.timestamp - a.timestamp; }); + recents = recents.slice(0, max_subjects); + recent_subjects[message.display_recipient] = recents; update_recent_subjects(); }