mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Move media file loading logic to the SDK. (#702)
* Adopt getMediaFile for media previewing.
This commit is contained in:
@@ -130,7 +130,6 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
|
||||
|
||||
return MediaProvider(mediaLoader: MediaLoader(client: client),
|
||||
imageCache: .onlyOnDisk,
|
||||
fileCache: FileCache.default,
|
||||
backgroundTaskService: nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ extension NotificationItemProxy {
|
||||
notification.body = "📷 " + content.body
|
||||
|
||||
notification = try await notification.addMediaAttachment(using: mediaProvider,
|
||||
mediaSource: .init(source: content.source))
|
||||
mediaSource: .init(source: content.source, mimeType: content.info?.mimetype))
|
||||
|
||||
return notification
|
||||
}
|
||||
@@ -186,7 +186,7 @@ extension NotificationItemProxy {
|
||||
notification.body = "📹 " + content.body
|
||||
|
||||
notification = try await notification.addMediaAttachment(using: mediaProvider,
|
||||
mediaSource: .init(source: content.source))
|
||||
mediaSource: .init(source: content.source, mimeType: content.info?.mimetype))
|
||||
|
||||
return notification
|
||||
}
|
||||
|
||||
@@ -24,11 +24,10 @@ extension UNMutableNotificationContent {
|
||||
guard let mediaProvider else {
|
||||
return self
|
||||
}
|
||||
|
||||
switch await mediaProvider.loadFileFromSource(mediaSource, fileExtension: "") {
|
||||
case .success(let url):
|
||||
switch await mediaProvider.loadFileFromSource(mediaSource) {
|
||||
case .success(let file):
|
||||
let attachment = try UNNotificationAttachment(identifier: ProcessInfo.processInfo.globallyUniqueString,
|
||||
url: url,
|
||||
url: file.url, // Needs testing: Does the file get copied before the media handle is be dropped?
|
||||
options: nil)
|
||||
attachments.append(attachment)
|
||||
case .failure(let error):
|
||||
@@ -47,14 +46,14 @@ extension UNMutableNotificationContent {
|
||||
return self
|
||||
}
|
||||
|
||||
switch await mediaProvider.loadFileFromSource(mediaSource, fileExtension: "jpg") {
|
||||
case .success(let url):
|
||||
switch await mediaProvider.loadFileFromSource(mediaSource) {
|
||||
case .success(let mediaFile):
|
||||
// Initialize only the sender for a one-to-one message intent.
|
||||
let handle = INPersonHandle(value: senderId, type: .unknown)
|
||||
let sender = try INPerson(personHandle: handle,
|
||||
nameComponents: nil,
|
||||
displayName: senderName,
|
||||
image: INImage(imageData: Data(contentsOf: url)),
|
||||
image: INImage(imageData: Data(contentsOf: mediaFile.url)),
|
||||
contactIdentifier: nil,
|
||||
customIdentifier: nil)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user