Browse Source

Merge pull request #8151 from nextcloud/bugfix/8121/fix-dashboard-widget-content

Adjust filtering and sorting to the same way the dashboard frontend does
pull/8161/head
Joas Schilling 3 years ago
committed by GitHub
parent
commit
1988ac24d6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      lib/Dashboard/TalkWidget.php
  2. 1
      src/views/Dashboard.vue
  3. 8
      tests/integration/features/integration/dashboard.feature

17
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 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;
}
}

1
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

8
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 | |
Loading…
Cancel
Save