diff --git a/lib/Dashboard/TalkWidget.php b/lib/Dashboard/TalkWidget.php index df80748455c..7cdb9230b7d 100644 --- a/lib/Dashboard/TalkWidget.php +++ b/lib/Dashboard/TalkWidget.php @@ -27,6 +27,7 @@ use OCA\Talk\Chat\MessageParser; use OCA\Talk\Manager; +use OCA\Talk\Participant; use OCA\Talk\Room; use OCA\Talk\Service\ParticipantService; use OCP\Comments\IComment; @@ -135,7 +136,9 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7): $rooms = array_filter($rooms, function (Room $room) use ($userId) { $participant = $this->participantService->getParticipant($room, $userId); $attendee = $participant->getAttendee(); - return $room->getLastMessage() && $room->getLastMessage()->getId() > $attendee->getLastReadMessage(); + return $room->getCallFlag() !== Participant::FLAG_DISCONNECTED + || $attendee->getLastMentionMessage() > $attendee->getLastReadMessage() + || ($room->getType() === Room::TYPE_ONE_TO_ONE && $room->getLastMessage() && $room->getLastMessage()->getId() > $attendee->getLastReadMessage()); }); uasort($rooms, [$this, 'sortRooms']); @@ -174,6 +177,12 @@ protected function prepareRoom(Room $room, string $userId): WidgetItem { } } + if ($room->getCallFlag() !== Participant::FLAG_DISCONNECTED) { + $subtitle = $this->l10n->t('Call in progress'); + } elseif ($participant->getAttendee()->getLastMentionMessage() > $participant->getAttendee()->getLastReadMessage()) { + $subtitle = $this->l10n->t('You were mentioned'); + } + return new WidgetItem( $room->getDisplayName($userId), $subtitle, @@ -211,6 +220,10 @@ protected function getRoomIconUrl(Room $room, string $userId): string { } protected function sortRooms(Room $roomA, Room $roomB): int { - return $roomA->getLastActivity() < $roomB->getLastActivity() ? -1 : 1; + if ($roomA->getCallFlag() !== $roomB->getCallFlag()) { + return $roomA->getCallFlag() !== Participant::FLAG_DISCONNECTED ? -1 : 1; + } + + return $roomA->getLastActivity() >= $roomB->getLastActivity() ? -1 : 1; } } diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 9b1d257835b..c8ed5c19544 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -190,6 +190,7 @@ export default { }) if (importantRooms.length) { + // FIXME unread 1-1 conversations are not sorted like unread mentions in group chats importantRooms.sort(propertySort(['-hasCall', '-unreadMention', '-lastActivity'])) this.roomOptions = importantRooms.slice(0, 7) this.hasImportantConversations = true diff --git a/tests/integration/features/integration/dashboard.feature b/tests/integration/features/integration/dashboard.feature index 63b5759f19c..b1ed7d87bbe 100644 --- a/tests/integration/features/integration/dashboard.feature +++ b/tests/integration/features/integration/dashboard.feature @@ -29,7 +29,7 @@ Feature: integration/dashboard And user "participant2" joins room "call room" with 200 (v4) And user "participant2" joins call "call room" with 200 (v4) Then user "participant1" sees the following entries for dashboard widgets "spreed" (v1) - | title | subtitle | link | iconUrl | sinceId | - | participant2-displayname | Hello | one-to-one room | {$BASE_URL}index.php/avatar/participant2/64 | | - | group room | Hello group room | group room | {$BASE_URL}core/img/actions/group.svg | | - | call room | @participant2-displayname started a call | call room | {$BASE_URL}core/img/actions/public.svg | | + | title | subtitle | link | iconUrl | sinceId | + | call room | Call in progress | call room | {$BASE_URL}core/img/actions/public.svg | | + | group room | You were mentioned | group room | {$BASE_URL}core/img/actions/group.svg | | + | participant2-displayname | Hello | one-to-one room | {$BASE_URL}index.php/avatar/participant2/64 | |