Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-08-31 11:37:22 +0300
committerJoas Schilling <coding@schilljs.com>2019-07-24 16:14:00 +0300
commit54692ebac3e55846ee91291f81e0d9192a06a138 (patch)
treea150c8e5916461f6f766c24c7c834f4f4d1041b0 /lib/Controller
parente1e62a59b1025056baf658f0ebfadc123d72557f (diff)
Change read marker to work on the comment id isntead of datetime
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Controller')
-rw-r--r--lib/Controller/ChatController.php13
-rw-r--r--lib/Controller/RoomController.php20
2 files changed, 28 insertions, 5 deletions
diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php
index 028e4f0f6..15249f4f2 100644
--- a/lib/Controller/ChatController.php
+++ b/lib/Controller/ChatController.php
@@ -267,12 +267,25 @@ class ChatController extends AEnvironmentAwareController {
$newLastKnown = end($comments);
if ($newLastKnown instanceof IComment) {
$response->addHeader('X-Chat-Last-Given', $newLastKnown->getId());
+ $this->participant->setLastReadMessage((int) $newLastKnown->getId());
}
return $response;
}
/**
+ * @NoAdminRequired
+ * @RequireParticipant
+ *
+ * @param int $lastReadMessage
+ * @return DataResponse
+ */
+ public function setReadMarker(int $lastReadMessage): DataResponse {
+ $this->participant->setLastReadMessage($lastReadMessage);
+ return new DataResponse();
+ }
+
+ /**
* @PublicPage
* @RequireParticipant
* @RequireReadWriteConversation
diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php
index 8bedb1bd5..5018ae37e 100644
--- a/lib/Controller/RoomController.php
+++ b/lib/Controller/RoomController.php
@@ -177,6 +177,7 @@ class RoomController extends AEnvironmentAwareController {
'hasPassword' => $room->hasPassword(),
'hasCall' => false,
'lastActivity' => 0,
+ 'lastReadMessage' => 0,
'unreadMessages' => 0,
'unreadMention' => false,
'isFavorite' => false,
@@ -227,12 +228,21 @@ class RoomController extends AEnvironmentAwareController {
$currentUser = $this->userManager->get($currentParticipant->getUser());
if ($currentUser instanceof IUser) {
- $unreadSince = $this->chatManager->getUnreadMarker($room, $currentUser);
- if ($currentParticipant instanceof Participant) {
- $lastMention = $currentParticipant->getLastMention();
- $roomData['unreadMention'] = $lastMention !== null && $unreadSince < $lastMention;
+ $lastReadMessage = $currentParticipant->getLastReadMessage();
+ if ($lastReadMessage === -1) {
+ /*
+ * Because the migration from the old comment_read_markers was
+ * not possible in a programmatic way with a reasonable O(1) or O(n)
+ * but only with O(userĂ—chat), we do the conversion here.
+ */
+ $lastReadMessage = $this->chatManager->getLastReadMessageFromLegacy($room, $currentUser);
+ $currentParticipant->setLastReadMessage($lastReadMessage);
}
- $roomData['unreadMessages'] = $this->chatManager->getUnreadCount($room, $unreadSince);
+ $roomData['unreadMessages'] = $this->chatManager->getUnreadCount($room, $lastReadMessage);
+
+ $lastMention = $currentParticipant->getLastMentionMessage();
+ $roomData['unreadMention'] = $lastMention !== 0 && $lastReadMessage < $lastMention;
+ $roomData['lastReadMessage'] = $lastReadMessage;
}
$numActiveGuests = 0;