parent
f6e57d664f
commit
96d42756d5
|
@ -42,7 +42,7 @@ class ImageGalleryDataSource: GalleryDataSource {
|
|||
gifController: gifController
|
||||
)
|
||||
} else {
|
||||
return LoadingGalleryContentViewController {
|
||||
return LoadingGalleryContentViewController(caption: nil) {
|
||||
let (data, image) = await self.cache.get(self.url, loadOriginal: true)
|
||||
if let image {
|
||||
let gifController: GIFController? =
|
||||
|
|
|
@ -10,6 +10,7 @@ import UIKit
|
|||
import GalleryVC
|
||||
|
||||
class LoadingGalleryContentViewController: UIViewController, GalleryContentViewController {
|
||||
private let fallbackCaption: String?
|
||||
private let provider: () async -> (any GalleryContentViewController)?
|
||||
private var wrapped: (any GalleryContentViewController)!
|
||||
|
||||
|
@ -24,14 +25,15 @@ class LoadingGalleryContentViewController: UIViewController, GalleryContentViewC
|
|||
}
|
||||
|
||||
var caption: String? {
|
||||
wrapped?.caption
|
||||
wrapped?.caption ?? fallbackCaption
|
||||
}
|
||||
|
||||
var canAnimateFromSourceView: Bool {
|
||||
wrapped?.canAnimateFromSourceView ?? true
|
||||
}
|
||||
|
||||
init(provider: @escaping () async -> (any GalleryContentViewController)?) {
|
||||
init(caption: String?, provider: @escaping () async -> (any GalleryContentViewController)?) {
|
||||
self.fallbackCaption = caption
|
||||
self.provider = provider
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
|
|
@ -57,7 +57,8 @@ class StatusAttachmentsGalleryDataSource: GalleryDataSource {
|
|||
gifController: gifController
|
||||
)
|
||||
} else {
|
||||
return LoadingGalleryContentViewController {
|
||||
return LoadingGalleryContentViewController(caption: attachment.description) {
|
||||
try! await Task.sleep(nanoseconds: NSEC_PER_SEC)
|
||||
let (data, image) = await ImageCache.attachments.get(attachment.url, loadOriginal: true)
|
||||
if let image {
|
||||
let gifController: GIFController? =
|
||||
|
@ -95,7 +96,7 @@ class StatusAttachmentsGalleryDataSource: GalleryDataSource {
|
|||
// TODO: use separate content VC with audio visualization?
|
||||
return VideoGalleryContentViewController(url: attachment.url, caption: attachment.description)
|
||||
case .unknown:
|
||||
return LoadingGalleryContentViewController {
|
||||
return LoadingGalleryContentViewController(caption: nil) {
|
||||
do {
|
||||
let (data, _) = try await URLSession.shared.data(from: attachment.url)
|
||||
let url = FileManager.default.temporaryDirectory.appendingPathComponent(attachment.url.lastPathComponent)
|
||||
|
|
Loading…
Reference in New Issue