Skip to content

Commit

Permalink
Fix for Talk-Widget direct mentions
Browse files Browse the repository at this point in the history
- Get last unread mention message using last unread mention id
- Only direct mentions are displayed in Talk-Widget
  • Loading branch information
Purva92Gupta committed Mar 25, 2024
1 parent d32c3f4 commit fc2d96a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
17 changes: 17 additions & 0 deletions lib/Service/ParticipantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1947,4 +1947,21 @@ public function getParticipantByActor(Room $room, string $actorType, string $act
$this->cacheParticipant($room, $participant);
return $participant;
}

/**
* @param int $mentionId
* @return string
*/
public function getLastUnreadMentionMessage(int $mentionId)
{
$query = $this->connection->getQueryBuilder();
$query->select('c.message')
->from('comments', 'c')
->where('c.id = :mentionId')
->setParameter('mentionId', $mentionId)
->setMaxResults(1);

$result = $query->executeQuery();
return $result->fetchOne();

Check failure on line 1965 in lib/Service/ParticipantService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

FalsableReturnStatement

lib/Service/ParticipantService.php:1965:10: FalsableReturnStatement: The declared return type 'string' for OCA\Talk\Service\ParticipantService::getLastUnreadMentionMessage does not allow false, but the function returns 'false|mixed' (see https://psalm.dev/137)
}
}
2 changes: 2 additions & 0 deletions lib/Service/RoomFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public function formatRoomV4(
'breakoutRoomMode' => BreakoutRoom::MODE_NOT_CONFIGURED,
'breakoutRoomStatus' => BreakoutRoom::STATUS_STOPPED,
'recordingConsent' => $this->talkConfig->recordingConsentRequired() === RecordingService::CONSENT_REQUIRED_OPTIONAL ? $room->getRecordingConsent() : $this->talkConfig->recordingConsentRequired(),
'lastUnreadMentionMessage' => '',
];

$lastActivity = $room->getLastActivity();
Expand Down Expand Up @@ -319,6 +320,7 @@ public function formatRoomV4(
$lastMentionDirect = $attendee->getLastMentionDirect();
$roomData['unreadMention'] = $lastMention !== 0 && $lastReadMessage < $lastMention;
$roomData['unreadMentionDirect'] = $lastMentionDirect !== 0 && $lastReadMessage < $lastMentionDirect;
$roomData['lastUnreadMentionMessage'] = ($lastMentionDirect !== 0 or $lastMentionDirect !== null) ? $this->participantService->getLastUnreadMentionMessage($lastMentionDirect) : '';
$roomData['lastReadMessage'] = $lastReadMessage;

$roomData['canDeleteConversation'] = $room->getType() !== Room::TYPE_ONE_TO_ONE
Expand Down
6 changes: 3 additions & 3 deletions src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ export default {
return t('spreed', 'Call in progress')
}

if (conversation.unreadMention) {
return t('spreed', 'You were mentioned')
if (conversation.unreadMentionDirect) {
return t('spreed', conversation.lastUnreadMentionMessage)
}

return this.simpleLastChatMessage(conversation.lastMessage)
Expand Down Expand Up @@ -188,7 +188,7 @@ export default {
const rooms = allRooms.filter((conversation) => conversation.objectType !== CONVERSATION.OBJECT_TYPE.BREAKOUT_ROOM)
const importantRooms = rooms.filter((conversation) => {
return conversation.hasCall
|| conversation.unreadMention
|| conversation.unreadMentionDirect
|| (conversation.unreadMessages > 0 && (conversation.type === CONVERSATION.TYPE.ONE_TO_ONE || conversation.type === CONVERSATION.TYPE.ONE_TO_ONE_FORMER))
})

Expand Down

0 comments on commit fc2d96a

Please sign in to comment.