From 06f95270db8b4fcb3eab13bbd9216739fa783794 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 20 Sep 2014 11:47:42 +0200 Subject: [PATCH] Fix loading activity events with same timestamp Fixes #1583 --- .../templates/dashboardBoxRecentActivity.tpl | 6 ++++-- wcfsetup/install/files/js/WCF.User.js | 2 ++ .../activity/event/UserActivityEventAction.class.php | 11 ++++++++++- .../event/ViewableUserActivityEventList.class.php | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/com.woltlab.wcf/templates/dashboardBoxRecentActivity.tpl b/com.woltlab.wcf/templates/dashboardBoxRecentActivity.tpl index c4e0287030..f41cf59460 100644 --- a/com.woltlab.wcf/templates/dashboardBoxRecentActivity.tpl +++ b/com.woltlab.wcf/templates/dashboardBoxRecentActivity.tpl @@ -6,7 +6,9 @@
-
@@ -22,4 +24,4 @@ new WCF.User.RecentActivityLoader(null, {if $filteredByFollowedUsers}true{else}false{/if}); }); //]]> - \ No newline at end of file + diff --git a/wcfsetup/install/files/js/WCF.User.js b/wcfsetup/install/files/js/WCF.User.js index c17e4e6382..21bbbe6af4 100644 --- a/wcfsetup/install/files/js/WCF.User.js +++ b/wcfsetup/install/files/js/WCF.User.js @@ -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 { diff --git a/wcfsetup/install/files/lib/data/user/activity/event/UserActivityEventAction.class.php b/wcfsetup/install/files/lib/data/user/activity/event/UserActivityEventAction.class.php index fe94888f63..65edd1577e 100644 --- a/wcfsetup/install/files/lib/data/user/activity/event/UserActivityEventAction.class.php +++ b/wcfsetup/install/files/lib/data/user/activity/event/UserActivityEventAction.class.php @@ -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') ); diff --git a/wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEventList.class.php b/wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEventList.class.php index 886a2286ca..4e5352cc1f 100644 --- a/wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEventList.class.php +++ b/wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEventList.class.php @@ -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. -- 2.20.1