fix: empty banner could be preview issue
This commit is contained in:
parent
206fe8d3bd
commit
c4b8f129d7
|
@ -5,6 +5,7 @@
|
|||
// Created by MainasuK on 2022-1-26.
|
||||
//
|
||||
|
||||
import os.log
|
||||
import UIKit
|
||||
import CoreDataStack
|
||||
import MastodonUI
|
||||
|
@ -153,6 +154,8 @@ extension DataSourceFacade {
|
|||
user: ManagedObjectRecord<MastodonUser>,
|
||||
previewContext: ImagePreviewContext
|
||||
) async throws {
|
||||
let logger = Logger(subsystem: "DataSourceFacade", category: "Media")
|
||||
|
||||
let managedObjectContext = dependency.context.managedObjectContext
|
||||
|
||||
var _avatarAssetURL: String?
|
||||
|
@ -216,13 +219,18 @@ extension DataSourceFacade {
|
|||
thumbnail: thumbnail
|
||||
))
|
||||
case .profileBanner:
|
||||
return .profileAvatar(.init(
|
||||
return .profileBanner(.init(
|
||||
assetURL: _headerAssetURL,
|
||||
thumbnail: thumbnail
|
||||
))
|
||||
}
|
||||
}()
|
||||
|
||||
guard mediaPreviewItem.isAssetURLValid else {
|
||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): discard preview due to assetURL invalid")
|
||||
return
|
||||
}
|
||||
|
||||
coordinateToMediaPreviewScene(
|
||||
dependency: dependency,
|
||||
mediaPreviewItem: mediaPreviewItem,
|
||||
|
|
|
@ -116,6 +116,19 @@ extension MediaPreviewViewModel {
|
|||
case profileAvatar(ProfileAvatarPreviewContext)
|
||||
case profileBanner(ProfileBannerPreviewContext)
|
||||
// case local(LocalImagePreviewMeta)
|
||||
|
||||
var isAssetURLValid: Bool {
|
||||
switch self {
|
||||
case .attachment:
|
||||
return true // default valid
|
||||
case .profileAvatar:
|
||||
return true // default valid
|
||||
case .profileBanner(let item):
|
||||
guard let assertURL = item.assetURL else { return false }
|
||||
guard !assertURL.hasSuffix("missing.png") else { return false }
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct AttachmentPreviewContext {
|
||||
|
|
Loading…
Reference in New Issue