summaryrefslogtreecommitdiff
path: root/plugins/Realtime/realtimeupdate.js
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Realtime/realtimeupdate.js')
-rw-r--r--plugins/Realtime/realtimeupdate.js25
1 files changed, 21 insertions, 4 deletions
diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js
index ea1f429b6..18834d03d 100644
--- a/plugins/Realtime/realtimeupdate.js
+++ b/plugins/Realtime/realtimeupdate.js
@@ -112,13 +112,15 @@ RealtimeUpdate = {
*
* @param {Object} data: extended JSON API-formatted notice
*
- * @fixme Ticket #2914: already-visible sent notices are still queued up
- * when paused, inflating the queue count
- *
* @access public
*/
receive: function(data)
{
+ if (RealtimeUpdate.isNoticeVisible(data.id)) {
+ // Probably posted by the user in this window, and so already
+ // shown by the AJAX form handler. Ignore it.
+ return;
+ }
if (RealtimeUpdate._paused === false) {
RealtimeUpdate.purgeLastNoticeItem();
@@ -149,7 +151,7 @@ RealtimeUpdate = {
*/
insertNoticeItem: function(data) {
// Don't add it if it already exists
- if ($("#notice-"+data.id).length > 0) {
+ if (RealtimeUpdate.isNoticeVisible(data.id)) {
return;
}
@@ -165,6 +167,21 @@ RealtimeUpdate = {
},
/**
+ * Check if the given notice is visible in the timeline currently.
+ * Used to avoid duplicate processing of notices that have been
+ * displayed by other means.
+ *
+ * @param {number} id: notice ID to check
+ *
+ * @return boolean
+ *
+ * @access private
+ */
+ isNoticeVisible: function(id) {
+ return ($("#notice-"+id).length > 0);
+ },
+
+ /**
* Trims a notice off the end of the timeline if we have more than the
* maximum number of notices visible.
*