diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-10-14 14:04:10 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2021-10-14 12:05:26 +0000 |
| commit | 0214dea9bd6c2e41e7a95a473a804bc8165d7438 (patch) | |
| tree | df2d85b9b3c3fe066bd968a1ca927c1095e4bf65 | |
| parent | 95e631f8b27ef8a6ea2d8f4f4b214537666af9dc (diff) | |
fix ordering of blubber threads, fixes #319
| -rw-r--r-- | lib/classes/sidebar/BlubberThreadsWidget.php | 1 | ||||
| -rw-r--r-- | lib/models/BlubberThread.php | 11 | ||||
| -rw-r--r-- | resources/vue/components/BlubberThreadWidget.vue | 6 |
3 files changed, 13 insertions, 5 deletions
diff --git a/lib/classes/sidebar/BlubberThreadsWidget.php b/lib/classes/sidebar/BlubberThreadsWidget.php index ab0bab7..b02e027 100644 --- a/lib/classes/sidebar/BlubberThreadsWidget.php +++ b/lib/classes/sidebar/BlubberThreadsWidget.php @@ -40,6 +40,7 @@ class BlubberThreadsWidget extends SidebarWidget 'avatar' => $thread->getAvatar(), 'name' => $thread->getName(), 'timestamp' => (int) $thread->getLatestActivity(), + 'mkdate' => (int) $thread->mkdate, 'unseen_comments' => $unseen_comments, 'notifications' => $thread->id === 'global' || ($thread->context_type === 'course' && !$GLOBALS['perm']->have_perm('admin')), 'followed' => $thread->isFollowedByUser(), diff --git a/lib/models/BlubberThread.php b/lib/models/BlubberThread.php index 7b0af06..cccaa3d 100644 --- a/lib/models/BlubberThread.php +++ b/lib/models/BlubberThread.php @@ -279,7 +279,7 @@ class BlubberThread extends SimpleORMap implements PrivacyObject ['olderthan' => $olderthan] ); } - $query->orderBy("IFNULL(MAX(blubber_comments.mkdate), blubber_threads.mkdate) DESC"); + $query->orderBy("MAX(blubber_comments.mkdate) DESC, blubber_threads.mkdate DESC"); $query->limit($limit); $threads = $query->fetchAll(static::class); @@ -291,7 +291,7 @@ class BlubberThread extends SimpleORMap implements PrivacyObject $since = 0; $olderthan = time(); foreach ($upgraded_threads as $thread) { - $active_time = $thread->getLatestActivity(); + $active_time = $thread->getLatestActivity(true); $since = max($since, $active_time); $olderthan = min($olderthan, $active_time); } @@ -581,10 +581,13 @@ class BlubberThread extends SimpleORMap implements PrivacyObject return OpenGraph::extract($this['content']); } - public function getLatestActivity() + public function getLatestActivity(bool $include_mkdate = false) { $newest_comment = BlubberComment::findOneBySQL("thread_id = ? ORDER BY mkdate DESC", [$this->getId()]); - return $newest_comment ? $newest_comment['mkdate'] : $this['mkdate']; + if ($newest_comment) { + return $newest_comment->mkdate; + } + return $include_mkdate ? $this->mkdate : null; } public function getURL() diff --git a/resources/vue/components/BlubberThreadWidget.vue b/resources/vue/components/BlubberThreadWidget.vue index 12514eb..2a2de1c 100644 --- a/resources/vue/components/BlubberThreadWidget.vue +++ b/resources/vue/components/BlubberThreadWidget.vue @@ -104,7 +104,11 @@ }, computed: { sortedThreads () { - return this.threads.sort((a, b) => b.timestamp - a.timestamp); + return this.threads.sort((a, b) => { + return b.timestamp - a.timestamp + || b.mkdate - a.mkdate + || b.name.localeCompare(a.name); + }); } } } |
