summaryrefslogtreecommitdiff
path: root/plugins/Realtime/realtimeupdate.js
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-11-30 16:46:11 -0800
committerBrion Vibber <brion@pobox.com>2010-11-30 16:46:11 -0800
commitc6f5975554db8421bebe52f9d17b5e4801d0a5bc (patch)
treea74175feba514b7bcc890419650651bfe36ff7ba /plugins/Realtime/realtimeupdate.js
parentf222e2132d921fc42fb9865b74538dfc1e6dd93e (diff)
Fix ticket #2914: Realtime no longer tells you it's got a message queued up when it's really the one you just sent out and is already visible.
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.
*