Placeholders added in push notifications (#1176)

* placeholders added in push notifications

* this code is a bit easier to read

* code improvement
This commit is contained in:
Mauro
2023-06-27 13:44:19 +02:00
committed by GitHub
parent 87cac534f5
commit 544d928287
6 changed files with 66 additions and 19 deletions
@@ -185,6 +185,15 @@ extension NotificationItemProxyProtocol {
}
}
var icon: NotificationIcon {
if isDirect {
return NotificationIcon(mediaSource: senderAvatarMediaSource, groupInfo: nil)
} else {
return NotificationIcon(mediaSource: roomAvatarMediaSource,
groupInfo: .init(name: roomDisplayName, id: roomID))
}
}
/// Process the receiver item proxy
/// - Parameters:
/// - receiverId: identifier of the user that has received the notification
@@ -236,13 +245,10 @@ extension NotificationItemProxyProtocol {
notification.categoryIdentifier = NotificationConstants.Category.invite
let icon: NotificationIcon
let body: String
if !isDirect {
icon = NotificationIcon(mediaSource: roomAvatarMediaSource, groupName: roomDisplayName)
body = L10n.notificationRoomInviteBody
} else {
icon = NotificationIcon(mediaSource: senderAvatarMediaSource, groupName: nil)
body = L10n.notificationInviteBody
}
@@ -292,17 +298,9 @@ extension NotificationItemProxyProtocol {
}
notification.categoryIdentifier = NotificationConstants.Category.message
let senderName = senderDisplayName ?? roomDisplayName
let icon: NotificationIcon
if !isDirect {
icon = NotificationIcon(mediaSource: roomAvatarMediaSource, groupName: roomDisplayName)
} else {
icon = NotificationIcon(mediaSource: senderAvatarMediaSource, groupName: nil)
}
notification = try await notification.addSenderIcon(using: mediaProvider,
senderID: event.senderID,
senderName: senderName,
senderName: senderDisplayName ?? roomDisplayName,
icon: icon)
return notification
}