<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -98,7 +98,7 @@
 			                 $created_at);
 
 			if (isset($_POST['ajax']))
-				exit(&quot;{ comment_id: &quot;.$_POST['id'].&quot; }&quot;);
+				exit(&quot;{ comment_id: &quot;.$_POST['id'].&quot;, comment_timestamp: \&quot;&quot;.$created_at.&quot;\&quot; }&quot;);
 
 			if ($_POST['status'] == &quot;spam&quot;)
 				Flash::notice(__(&quot;Comment updated.&quot;), &quot;/admin/?action=manage_spam&quot;);
@@ -425,9 +425,9 @@
 					$post = new Post($_POST['post_id']);
 					if ($post-&gt;latest_comment &gt; $_POST['last_comment']) {
 						$new_comments = $sql-&gt;select(&quot;comments&quot;,
-						                             &quot;id&quot;,
+						                             &quot;id, created_at&quot;,
 						                             array(&quot;post_id&quot; =&gt; $_POST['post_id'],
-						                                   &quot;id &gt;&quot; =&gt; $_POST['last_comment'],
+						                                   &quot;created_at &gt;&quot; =&gt; $_POST['last_comment'],
 						                                   &quot;status not&quot; =&gt; &quot;spam&quot;,
 						                                   &quot;status != 'denied' OR (
 						                                        (
@@ -440,12 +440,16 @@
 						                             &quot;created_at ASC&quot;,
 						                             array(&quot;:visitor_id&quot; =&gt; $visitor-&gt;id));
 
-						error_log(print_r($new_comments, true));
 						$ids = array();
-						while ($the_comment = $new_comments-&gt;fetchObject())
+						$last_comment = &quot;&quot;;
+						while ($the_comment = $new_comments-&gt;fetchObject()) {
 							$ids[] = $the_comment-&gt;id;
+
+							if (strtotime($last_comment) &lt; strtotime($the_comment-&gt;created_at))
+								$last_comment = $the_comment-&gt;created_at;
+						}
 ?&gt;
-{ &quot;comment_ids&quot;: [ &lt;?php echo implode(&quot;, &quot;, $ids); ?&gt; ] }
+{ comment_ids: [ &lt;?php echo implode(&quot;, &quot;, $ids); ?&gt; ], last_comment: &quot;&lt;?php echo $last_comment; ?&gt;&quot; }
 &lt;?php
 					}
 					break;</diff>
      <filename>modules/comments/comments.php</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,7 @@ $(function(){
 &lt;?php if ($config-&gt;auto_reload_comments and $config-&gt;enable_reload_comments): ?&gt;
 		var updater = setInterval(&quot;Comment.reload()&quot;, &lt;?php echo $config-&gt;auto_reload_comments * 1000; ?&gt;);
 &lt;?php endif; ?&gt;
-		$(&quot;#add_comment&quot;).append($(document.createElement(&quot;input&quot;)).attr({ type: &quot;hidden&quot;, name: &quot;ajax&quot;, value: &quot;true&quot;, id: &quot;ajax&quot; }));
+		$(&quot;#add_comment&quot;).append($(document.createElement(&quot;input&quot;)).attr({ type: &quot;hidden&quot;, name: &quot;ajax&quot;, value: &quot;true&quot;, id: &quot;ajax&quot; }))
 		$(&quot;#add_comment&quot;).ajaxForm({ dataType: &quot;json&quot;, resetForm: true, beforeSubmit: function(){
 			$(&quot;#add_comment&quot;).loader();
 		}, success: function(json){
@@ -22,7 +22,7 @@ $(function(){
 					var plural = (count == 1) ? &quot;&quot; : &quot;s&quot;
 					$(&quot;.comment_plural&quot;).text(plural)
 				}
-				$(&quot;#last_comment&quot;).val(json.comment_id)
+				$(&quot;#last_comment&quot;).val(json.comment_timestamp)
 				$(data).appendTo(&quot;.comments:not(:header)&quot;).hide().fadeIn(&quot;slow&quot;)
 			})
 		}, complete: function(){
@@ -64,8 +64,8 @@ var Comment = {
 		var id = $(&quot;.comments:not(:header)&quot;).attr(&quot;id&quot;).replace(/comments_/, &quot;&quot;)
 		if (editing == 0 &amp;&amp; notice == 0 &amp;&amp; $(&quot;.comments:not(:header)&quot;).children().size() &lt; &lt;?php echo $config-&gt;comments_per_page; ?&gt;) {
 			$.ajax({ type: &quot;post&quot;, dataType: &quot;json&quot;, url: &quot;&lt;?php echo $config-&gt;chyrp_url; ?&gt;/includes/ajax.php&quot;, data: &quot;action=reload_comments&amp;post_id=&quot;+id+&quot;&amp;last_comment=&quot;+$(&quot;#last_comment&quot;).val(), success: function(json) {
+				$(&quot;#last_comment&quot;).val(json.last_comment)
 				$.each(json.comment_ids, function(i, id) {
-					$(&quot;#last_comment&quot;).val(id)
 					$.post(&quot;&lt;?php echo $config-&gt;chyrp_url; ?&gt;/includes/ajax.php&quot;, { action: &quot;show_comment&quot;, comment_id: id }, function(data){
 						$(data).appendTo(&quot;.comments:not(:header)&quot;).hide().fadeIn(&quot;slow&quot;)
 					})</diff>
      <filename>modules/comments/javascript.php</filename>
    </modified>
    <modified>
      <diff>@@ -14,6 +14,9 @@
 		public function __construct($comment_id, $options = array()) {
 			parent::grab($this, $comment_id, $options);
 
+			if ($this-&gt;no_results)
+				return false;
+
 			$this-&gt;body_unfiltered = $this-&gt;body;
 			$group = ($this-&gt;user_id and !$this-&gt;user()-&gt;no_results) ? $this-&gt;user()-&gt;group() : new Group(Config::current()-&gt;guest_group) ;
 
@@ -110,7 +113,7 @@
 					$_SESSION['comments'][] = $comment-&gt;id;
 
 					if (isset($_POST['ajax']))
-						exit(&quot;{ comment_id: &quot;.$comment-&gt;id.&quot; }&quot;);
+						exit(&quot;{ comment_id: &quot;.$comment-&gt;id.&quot;, comment_timestamp: \&quot;&quot;.$comment-&gt;created_at.&quot;\&quot; }&quot;);
 
 					Flash::notice(__(&quot;Comment added.&quot;), $post-&gt;url().&quot;#comment_&quot;.$comment-&gt;id);
 				}
@@ -132,7 +135,7 @@
 				$_SESSION['comments'][] = $comment-&gt;id;
 
 				if (isset($_POST['ajax']))
-					exit(&quot;{ comment_id: &quot;.$comment-&gt;id.&quot; }&quot;);
+					exit(&quot;{ comment_id: &quot;.$comment-&gt;id.&quot;, comment_timestamp: \&quot;&quot;.$comment-&gt;created_at.&quot;\&quot; }&quot;);
 
 				Flash::notice(__(&quot;Comment added.&quot;), $post-&gt;url().&quot;#comment_&quot;.$comment-&gt;id);
 			}</diff>
      <filename>modules/comments/model.Comment.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3adf78dfab6e39235682694388d7913361a3a7a4</id>
    </parent>
  </parents>
  <author>
    <name>Alex Suraci</name>
    <email>i.am@toogeneric.com</email>
  </author>
  <url>http://github.com/vito/chyrp/commit/351a1a8fd43618ddcf5b8227c64a1217df797efd</url>
  <id>351a1a8fd43618ddcf5b8227c64a1217df797efd</id>
  <committed-date>2008-09-04T14:10:04-07:00</committed-date>
  <authored-date>2008-09-04T14:10:04-07:00</authored-date>
  <message>Refactored and fixed AJAX comment autoreloading.</message>
  <tree>61525ac31f7fb4af888fab1c305df7d06f283db2</tree>
  <committer>
    <name>Alex Suraci</name>
    <email>i.am@toogeneric.com</email>
  </committer>
</commit>
