Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-10-12 11:11:38 +0300
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2022-10-12 19:59:49 +0300
commit3a237416aa0fcd3a1ac6ecccc29015ae59ab91fa (patch)
tree3499e95e2f56f9ae6eb6f2023d79c0660f2e787a /lib
parent3fe3b7a7576c42305faae4caf8cccd5a310387c4 (diff)
Adjust filtering and sorting to the same way the dashboard frontend does
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Dashboard/TalkWidget.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/Dashboard/TalkWidget.php b/lib/Dashboard/TalkWidget.php
index 3516f7cc3..1be4cd1eb 100644
--- a/lib/Dashboard/TalkWidget.php
+++ b/lib/Dashboard/TalkWidget.php
@@ -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 OCP\Comments\IComment;
use OCP\Dashboard\IAPIWidget;
@@ -131,7 +132,9 @@ class TalkWidget implements IAPIWidget, IIconWidget, IButtonWidget, IOptionWidge
$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']);
@@ -170,6 +173,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,
@@ -207,6 +216,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;
}
}