Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/Dashboard/TalkWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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']);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
}
1 change: 1 addition & 0 deletions src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export default {
})

if (importantRooms.length) {
// FIXME unread 1-1 conversations are not sorted like unread mentions in group chats
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// FIXME unread 1-1 conversations are not sorted like unread mentions in group chats
/** @todo FIXME unread 1-1 conversations are not sorted like unread mentions in group chats **/

What you think? Is best use the annotation and in a future we can search only by @toto to check all that we neet to pay attention and fix.

importantRooms.sort(propertySort(['-hasCall', '-unreadMention', '-lastActivity']))
this.roomOptions = importantRooms.slice(0, 7)
this.hasImportantConversations = true
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/features/integration/dashboard.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |