public function SetWatch($Discussion, $Limit, $Offset, $TotalComments) {
      
      $NewComments = FALSE;
      
      $Session = Gdn::Session();
      if ($Session->UserID > 0) {
         
         // Max comments we could have seen
         $CountWatch = $Limit * ($Offset + 1);
         if ($CountWatch > $TotalComments)
            $CountWatch = $TotalComments;
         
         // This dicussion looks familiar...
         if (is_numeric($Discussion->CountCommentWatch)) {
            
            if (isset($Discussion->DateLastViewed))
               $NewComments |= Gdn_Format::ToTimestamp($Discussion->DateLastComment) > Gdn_Format::ToTimestamp($Discussion->DateLastViewed);
            
            if ($TotalComments > $Discussion->CountCommentWatch)
               $NewComments |= TRUE;

            // Update the watch data.
				if ($NewComments) {
               
					// Only update the watch if there are new comments.
					$this->SQL->Put(
						'UserDiscussion',
						array(
							'CountComments' => $CountWatch,
                     'DateLastViewed' => Gdn_Format::ToDateTime()
						),
						array(
							'UserID' => $Session->UserID,
							'DiscussionID' => $Discussion->DiscussionID
						)
					);
				}
            
         } else {
				// Make sure the discussion isn't archived.
				$ArchiveDate = C('Vanilla.Archive.Date', FALSE);
				if (!$ArchiveDate || (Gdn_Format::ToTimestamp($Discussion->DateLastComment) > Gdn_Format::ToTimestamp($ArchiveDate))) {
               
               $NewComments = TRUE;
               
					// Insert watch data.
               $this->SQL->Options('Ignore', TRUE);
					$this->SQL->Insert(
						'UserDiscussion',
						array(
							'UserID' => $Session->UserID,
							'DiscussionID' => $Discussion->DiscussionID,
							'CountComments' => $CountWatch,
                     'DateLastViewed' => Gdn_Format::ToDateTime()
						)
					);
				}
			}
         
         /**
          * Fuzzy way of trying to automatically mark a cateogyr read again
          * if the user reads all the comments on the first few pages.
          */
         
         // If this discussion is in a category that has been marked read, 
         // check if reading this thread causes it to be completely read again
         $CategoryID = GetValue('CategoryID', $Discussion);
         if ($CategoryID) {
            
            $Category = CategoryModel::Categories($CategoryID);
            if ($Category) {
               
               $DateMarkedRead = GetValue('DateMarkedRead', $Category);
               if ($DateMarkedRead) {
                  
                  // Fuzzy way of looking back about 2 pages into the past
                  $LookBackCount = C('Vanilla.Discussions.PerPage', 50) * 2;
                  
                  // Find all discussions with content from after DateMarkedRead
                  $DiscussionModel = new DiscussionModel();
                  $Discussions = $DiscussionModel->Get(0, 101, array(
                     'CategoryID'         => $CategoryID,
                     'DateLastComment>'   => $DateMarkedRead
                  ));
                  unset($DiscussionModel);
                  
                  // Abort if we get back as many as we asked for, meaning a 
                  // lot has happened.
                  $NumDiscussions = $Discussions->NumRows();
                  if ($NumDiscussions <= $LookBackCount) {
                  
                     // Loop over these and see if any are still unread
                     $MarkAsRead = TRUE;
                     while ($Discussion = $Discussions->NextRow(DATASET_TYPE_ARRAY)) {
                        if ($Discussion['Read']) continue;
                        $MarkAsRead = FALSE;
                        break;
                     }

                     // Mark this category read if all the new content is read
                     if ($MarkAsRead) {
                        $CategoryModel = new CategoryModel();
                        $CategoryModel->SaveUserTree($CategoryID, array('DateMarkedRead' => Gdn_Format::ToDateTime()));
                        unset($CategoryModel);
                     }
                     
                  }
               }
            }
         }
         
		}
   }