mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +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)
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ targets:
|
||||
- path: ../../ElementX/Sources/Services/Media
|
||||
- path: ../../ElementX/Sources/Services/Background/BackgroundTaskServiceProtocol.swift
|
||||
- path: ../../ElementX/Sources/Services/Background/BackgroundTaskProtocol.swift
|
||||
- path: ../../ElementX/Sources/Services/Cache/FileCache.swift
|
||||
- path: ../../ElementX/Sources/Other/Logging
|
||||
- path: ../../ElementX/Sources/Other/Extensions/Task.swift
|
||||
- path: ../../ElementX/Sources/Other/Extensions/FileManager.swift
|
||||
@@ -87,5 +86,6 @@ targets:
|
||||
- path: ../../ElementX/Sources/Other/Extensions/Bundle.swift
|
||||
- path: ../../ElementX/Sources/Other/Extensions/Date.swift
|
||||
- path: ../../ElementX/Sources/Other/Extensions/ImageCache.swift
|
||||
- path: ../../ElementX/Sources/Other/Extensions/UTType.swift
|
||||
- path: ../../ElementX/Sources/Other/AvatarSize.swift
|
||||
- path: ../../ElementX/Sources/Other/InfoPlistReader.swift
|
||||
|
||||
Reference in New Issue
Block a user