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 OCP\Comments\IComment;
use OCP\Dashboard\IAPIWidget;
Expand Down Expand Up @@ -131,7 +132,9 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
$rooms = array_filter($rooms, static function (Room $room) use ($userId) {
$participant = $room->getParticipant($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 @@ -170,6 +173,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 @@ -207,6 +216,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
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 | |