Don't assume we will always have updates.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 12 Aug 2010 17:43:14 +0000 (13:43 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 12 Aug 2010 17:43:39 +0000 (13:43 -0400)
horde/js/twitterclient.js
horde/services/twitter.php

index 20ff458..2829c84 100644 (file)
@@ -41,7 +41,7 @@ var Horde_Twitter = Class.create({
         $(this.opts.input).observe('keyup', function() {
             $(this.opts.counter).update(140 - $F(this.opts.input).length);
         }.bind(this));
-        
+
         /* Get the first page */
         this.getNewEntries();
    },
@@ -152,25 +152,26 @@ var Horde_Twitter = Class.create({
     /**
      * Callback for retrieving new entries. Updates the display and remembers
      * the newest id, and possible the older id as well.
-     * 
+     *
      */
     _getNewEntriesCallback: function(response) {
         var content = response.responseJSON.c;
-        var h = $(this.opts.content).scrollHeight
-        $(this.opts.content).insert({ 'top': content });
-        // Don't scroll if it's the first request.
-        if (this.newestId) {
-            $(this.opts.content).scrollTop = h;
-        } else {
-            $(this.opts.content).scrollTop = 0;
-        }
-        this.newestId = response.responseJSON.n;
+        if (response.responseJSON.n != this.newestId) {
+            var h = $(this.opts.content).scrollHeight
+            $(this.opts.content).insert({ 'top': content });
+            // Don't scroll if it's the first request.
+            if (this.newestId) {
+                $(this.opts.content).scrollTop = h;
+            } else {
+                $(this.opts.content).scrollTop = 0;
+            }
+            this.newestId = response.responseJSON.n;
 
-        // First time we've been called, record the oldest one as well.'
-        if (!this.oldestId) {
-            this.oldestId = response.responseJSON.o;
+            // First time we've been called, record the oldest one as well.'
+            if (!this.oldestId) {
+                this.oldestId = response.responseJSON.o;
+            }
         }
-        
         new PeriodicalExecuter(function(pe) { this.getNewEntries(); pe.stop(); }.bind(this), this.opts.refreshrate );
     },
 
index cda42c7..99fcd8e 100644 (file)
@@ -63,7 +63,12 @@ case 'getPage':
         exit;
     }
     $html = '';
-    $newest = $stream[0]->id;
+    if (count($stream)) {
+        $newest = $stream[0]->id;
+    } else {
+        $newest = $params['since_id'];
+        $oldest = 0;
+    }
     foreach ($stream as $tweet) {
          $view = new Horde_View(array('templatePath' => HORDE_TEMPLATES . '/block'));
          $view->addHelper('Tag');