Fix loading activity events with same timestamp
authorMatthias Schmidt <gravatronics@live.com>
Sat, 20 Sep 2014 09:47:42 +0000 (11:47 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 20 Sep 2014 09:47:42 +0000 (11:47 +0200)
Fixes #1583

com.woltlab.wcf/templates/dashboardBoxRecentActivity.tpl
wcfsetup/install/files/js/WCF.User.js
wcfsetup/install/files/lib/data/user/activity/event/UserActivityEventAction.class.php
wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEventList.class.php

index c4e0287030e62993dfa68582ba4d7feb42b65d58..f41cf59460be2a7d15693af067d112780439699b 100644 (file)
@@ -6,7 +6,9 @@
 </header>
 
 <div class="container marginTop">
-       <ul id="recentActivities" class="containerList recentActivityList" data-last-event-time="{@$lastEventTime}">
+       {assign var='__events' value=$eventList->getObjects()}
+       {assign var='__lastEvent' value=$__events|end}
+       <ul id="recentActivities" class="containerList recentActivityList" data-last-event-time="{@$lastEventTime}" data-last-event-id="{@$__lastEvent->eventID}">
                {include file='recentActivityListItem'}
        </ul>
 </div>
@@ -22,4 +24,4 @@
                new WCF.User.RecentActivityLoader(null, {if $filteredByFollowedUsers}true{else}false{/if});
        });
        //]]>
-</script>
\ No newline at end of file
+</script>
index c17e4e63824194cac12591fa4e44f2d235eec4e6..21bbbe6af4b7c7935cba34a1b19f5fd1c105ec88 100644 (file)
@@ -1650,6 +1650,7 @@ WCF.User.RecentActivityLoader = Class.extend({
                this._loadButton.enable();
                
                var $parameters = {
+                       lastEventID: this._container.data('lastEventID'),
                        lastEventTime: this._container.data('lastEventTime')
                };
                if (this._userID) {
@@ -1695,6 +1696,7 @@ WCF.User.RecentActivityLoader = Class.extend({
                        $(data.returnValues.template).insertBefore(this._loadButton.parent());
                        
                        this._container.data('lastEventTime', data.returnValues.lastEventTime);
+                       this._container.data('lastEventID', data.returnValues.lastEventID);
                        this._loadButton.enable();
                }
                else {
index fe94888f6371783e4d695fe9506f427e421a552c..65edd1577e2d7255975b4a1dfa8541328faf1c0d 100644 (file)
@@ -28,6 +28,7 @@ class UserActivityEventAction extends AbstractDatabaseObjectAction {
        public function validateLoad() {
                $this->readBoolean('filteredByFollowedUsers', true);
                $this->readInteger('lastEventTime');
+               $this->readInteger('lastEventID', true);
                $this->readInteger('userID', true);
        }
        
@@ -38,7 +39,13 @@ class UserActivityEventAction extends AbstractDatabaseObjectAction {
         */
        public function load() {
                $eventList = new ViewableUserActivityEventList();
-               $eventList->getConditionBuilder()->add("user_activity_event.time < ?", array($this->parameters['lastEventTime']));
+               if ($this->parameters['lastEventID']) {
+                       $eventList->getConditionBuilder()->add("user_activity_event.time <= ?", array($this->parameters['lastEventTime']));
+                       $eventList->getConditionBuilder()->add("user_activity_event.eventID < ?", array($this->parameters['lastEventID']));
+               }
+               else {
+                       $eventList->getConditionBuilder()->add("user_activity_event.time < ?", array($this->parameters['lastEventTime']));
+               }
                
                // profile view
                if ($this->parameters['userID']) {
@@ -63,7 +70,9 @@ class UserActivityEventAction extends AbstractDatabaseObjectAction {
                        'eventList' => $eventList
                ));
                
+               $events = $eventList->getObjects();
                return array(
+                       'lastEventID' => end($events)->eventID,
                        'lastEventTime' => $lastEventTime,
                        'template' => WCF::getTPL()->fetch('recentActivityListItem')
                );
index 886a2286ca29ab14842d3b7d2d26148aa5037ae6..4e5352cc1fd8cff45e83d670ede52cf0ee0ae970 100644 (file)
@@ -29,7 +29,7 @@ class ViewableUserActivityEventList extends UserActivityEventList {
        /**
         * @see \wcf\data\DatabaseObjectList::$sqlOrderBy
         */
-       public $sqlOrderBy = 'user_activity_event.time DESC';
+       public $sqlOrderBy = 'user_activity_event.time DESC, user_activity_event.eventID DESC';
        
        /**
         * Creates a new ViewableUserActivityEventList object.