|
|
|
@ -27,6 +27,7 @@ namespace OCA\Talk\Dashboard; |
|
|
|
|
|
|
|
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 @@ class TalkWidget implements IAPIWidget, IIconWidget, IButtonWidget, IOptionWidge |
|
|
|
$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 @@ class TalkWidget implements IAPIWidget, IIconWidget, IButtonWidget, IOptionWidge |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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 @@ class TalkWidget implements IAPIWidget, IIconWidget, IButtonWidget, IOptionWidge |
|
|
|
} |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
} |