mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Handle media previews and invite avatars through the account data (#4142)
* added account data media display policy handling to NSE * pr suggestions * update compound * code improvement
This commit is contained in:
@@ -18,6 +18,28 @@ final class NSEUserSession {
|
||||
imageCache: .onlyOnDisk,
|
||||
networkMonitor: nil)
|
||||
private let delegateHandle: TaskHandle?
|
||||
|
||||
var mediaPreviewVisibility: MediaPreviews {
|
||||
get async {
|
||||
do {
|
||||
return try await baseClient.getMediaPreviewDisplayPolicy() ?? .on
|
||||
} catch {
|
||||
MXLog.error("Failed to get media preview visibility, defaulting to on. Error: \(error)")
|
||||
return .on
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var inviteAvatarsVisibility: InviteAvatars {
|
||||
get async {
|
||||
do {
|
||||
return try await baseClient.getInviteAvatarsDisplayPolicy() ?? .on
|
||||
} catch {
|
||||
MXLog.error("Failed to get invite avatars visibility, defaulting to on. Error: \(error)")
|
||||
return .on
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(credentials: KeychainCredentials,
|
||||
roomID: String,
|
||||
|
||||
@@ -15,7 +15,7 @@ import Version
|
||||
|
||||
struct NotificationContentBuilder {
|
||||
let messageEventStringBuilder: RoomMessageEventStringBuilder
|
||||
let settings: CommonSettingsProtocol
|
||||
let userSession: NSEUserSession
|
||||
|
||||
/// Process the given notification item proxy
|
||||
/// - Parameters:
|
||||
@@ -104,7 +104,7 @@ struct NotificationContentBuilder {
|
||||
senderID: notificationItem.senderID,
|
||||
senderName: notificationItem.senderDisplayName ?? notificationItem.roomDisplayName,
|
||||
icon: icon(for: notificationItem),
|
||||
forcePlaceholder: settings.hideInviteAvatars,
|
||||
forcePlaceholder: userSession.inviteAvatarsVisibility == .off,
|
||||
mediaProvider: mediaProvider)
|
||||
}
|
||||
|
||||
@@ -146,8 +146,9 @@ struct NotificationContentBuilder {
|
||||
let displayName = notificationItem.senderDisplayName ?? notificationItem.roomDisplayName
|
||||
notificationContent.body = String(messageEventStringBuilder.buildAttributedString(for: messageType, senderDisplayName: displayName, isOutgoing: false).characters)
|
||||
|
||||
guard settings.timelineMediaVisibility == .always ||
|
||||
(settings.timelineMediaVisibility == .privateOnly && notificationItem.isRoomPrivate)
|
||||
let timelineMediaVisibility = await userSession.mediaPreviewVisibility
|
||||
guard timelineMediaVisibility == .on ||
|
||||
(timelineMediaVisibility == .private && notificationItem.isRoomPrivate)
|
||||
else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class NotificationHandler {
|
||||
destination: .notification)
|
||||
|
||||
notificationContentBuilder = NotificationContentBuilder(messageEventStringBuilder: eventStringBuilder,
|
||||
settings: settings)
|
||||
userSession: userSession)
|
||||
}
|
||||
|
||||
func processEvent(_ eventID: String, roomID: String) async {
|
||||
|
||||
Reference in New Issue
Block a user