From 0d20e25f58170434d81df36e14fe5962cd9706ad Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 2 Dec 2024 15:47:15 +0100 Subject: [PATCH] fix(chat): Fix infinite loading spinner when someone cleared the history Signed-off-by: Joas Schilling --- lib/Service/ParticipantService.php | 3 ++- tests/integration/features/chat-1/delete.feature | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php index 356c8c0151b..73388147a54 100644 --- a/lib/Service/ParticipantService.php +++ b/lib/Service/ParticipantService.php @@ -12,6 +12,7 @@ use OCA\Circles\Model\Circle; use OCA\Circles\Model\Member; use OCA\Talk\CachePrefix; +use OCA\Talk\Chat\ChatManager; use OCA\Talk\Config; use OCA\Talk\Events\AAttendeeRemovedEvent; use OCA\Talk\Events\AParticipantModifiedEvent; @@ -1407,7 +1408,7 @@ public function markUsersAsMentioned(Room $room, string $actorType, array $actor public function resetChatDetails(Room $room): void { $update = $this->connection->getQueryBuilder(); $update->update('talk_attendees') - ->set('last_read_message', $update->createNamedParameter(0, IQueryBuilder::PARAM_INT)) + ->set('last_read_message', $update->createNamedParameter(ChatManager::UNREAD_FIRST_MESSAGE, IQueryBuilder::PARAM_INT)) ->set('last_mention_message', $update->createNamedParameter(0, IQueryBuilder::PARAM_INT)) ->set('last_mention_direct', $update->createNamedParameter(0, IQueryBuilder::PARAM_INT)) ->set('last_attendee_activity', $update->createNamedParameter($this->timeFactory->getTime(), IQueryBuilder::PARAM_INT)) diff --git a/tests/integration/features/chat-1/delete.feature b/tests/integration/features/chat-1/delete.feature index ed8a53e4875..4c3cd8d36e8 100644 --- a/tests/integration/features/chat-1/delete.feature +++ b/tests/integration/features/chat-1/delete.feature @@ -214,7 +214,19 @@ Feature: chat/delete | room | actorType | actorId | actorDisplayName | message | messageParameters | | room1 | users | participant2 | participant2-displayname | Message 2 | [] | | room1 | users | participant1 | participant1-displayname | Message 1 | [] | + Then user "participant1" is participant of room "room1" (v4) + | unreadMessages | lastReadMessage | + | 1 | Message 1 | + Then user "participant2" is participant of room "room1" (v4) + | unreadMessages | lastReadMessage | + | 0 | Message 2 | And user "participant1" deletes chat history for room "room1" with 200 + Then user "participant1" is participant of room "room1" (v4) + | unreadMessages | lastReadMessage | + | 1 | FIRST_MESSAGE_UNREAD | + Then user "participant2" is participant of room "room1" (v4) + | unreadMessages | lastReadMessage | + | 1 | FIRST_MESSAGE_UNREAD | Then user "participant1" sees the following messages in room "room1" with 200 | room | actorType | actorId | actorDisplayName | message | messageParameters | Then user "participant1" sees the following system messages in room "room1" with 200 (v1)