|
@@ -228,8 +228,12 @@ func getFilesDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escapi
|
|
|
imageRecent = image
|
|
|
} else if file.hasPreview {
|
|
|
do {
|
|
|
- if let imageIcon = try await downloadPreview(file: file, account: account.account) {
|
|
|
- imageRecent = imageIcon
|
|
|
+ let fileNamePathOrFileId = CCUtility.returnFileNamePath(fromFileName: file.fileName, serverUrl: file.serverUrl, urlBase: file.urlBase, account: account.account)!
|
|
|
+ let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(file.ocId, etag: file.etag)!
|
|
|
+ let fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(file.ocId, etag: file.etag)!
|
|
|
+ let (_, _, imageIcon, _, _) = try await NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePathOrFileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, widthPreview: NCGlobal.shared.sizePreview, heightPreview: NCGlobal.shared.sizePreview, fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon)
|
|
|
+ if let image = imageIcon {
|
|
|
+ imageRecent = image
|
|
|
}
|
|
|
} catch {
|
|
|
print(error)
|
|
@@ -256,25 +260,4 @@ func getFilesDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escapi
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // Wrapper
|
|
|
- @Sendable func downloadPreview(file: NKFile, account: String) async throws -> UIImage? {
|
|
|
-
|
|
|
- try await withUnsafeThrowingContinuation { continuation in
|
|
|
-
|
|
|
- let fileNamePathOrFileId = CCUtility.returnFileNamePath(fromFileName: file.fileName, serverUrl: file.serverUrl, urlBase: file.urlBase, account: account)!
|
|
|
- let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(file.ocId, etag: file.etag)!
|
|
|
- let fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(file.ocId, etag: file.etag)!
|
|
|
-
|
|
|
- NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePathOrFileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, widthPreview: NCGlobal.shared.sizePreview, heightPreview: NCGlobal.shared.sizePreview, fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, etag: nil) { account, imagePreview, imageIcon, imageOriginal, etag, nkerror in
|
|
|
-
|
|
|
- if nkerror == .success {
|
|
|
- continuation.resume(returning: imageIcon)
|
|
|
- } else {
|
|
|
- continuation.resume(throwing: NSError(domain: NSCocoaErrorDomain, code: nkerror.errorCode, userInfo: [NSLocalizedDescriptionKey:nkerror.description]))
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
-
|