More permissive sticker-attachment rendering
This commit is contained in:
parent
0d0c82eb96
commit
edca6e0db9
@ -39,12 +39,6 @@ public class CVComponentStateWrapper: NSObject, CVItemViewModel {
|
||||
return componentState.stickerAttachment
|
||||
}
|
||||
|
||||
public var stickerInfo: StickerInfo? {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
return componentState.stickerInfo
|
||||
}
|
||||
|
||||
public var linkPreview: OWSLinkPreview? {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
@ -317,10 +311,6 @@ public extension CVComponentState {
|
||||
sticker?.attachmentStream?.attachmentStream
|
||||
}
|
||||
|
||||
var stickerInfo: StickerInfo? {
|
||||
sticker?.stickerMetadata?.stickerInfo
|
||||
}
|
||||
|
||||
var linkPreviewModel: OWSLinkPreview? {
|
||||
linkPreview?.linkPreview
|
||||
}
|
||||
|
||||
@ -1305,24 +1305,11 @@ fileprivate extension CVComponentState.Builder {
|
||||
throw OWSAssertionError("Missing sticker attachment.")
|
||||
}
|
||||
if let attachmentStream = attachment.asReferencedStream {
|
||||
switch attachmentStream.attachmentStream.contentType {
|
||||
case .image(let pixelSize), .animatedImage(let pixelSize):
|
||||
guard pixelSize.isNonEmpty else {
|
||||
fallthrough
|
||||
}
|
||||
default:
|
||||
throw OWSAssertionError("Invalid sticker.")
|
||||
}
|
||||
let stickerType = StickerManager.stickerType(forContentType: attachmentStream.attachment.mimeType)
|
||||
guard
|
||||
let stickerMetadata = attachmentStream.attachmentStream.asStickerMetadata(
|
||||
stickerInfo: messageSticker.info,
|
||||
stickerType: stickerType,
|
||||
emojiString: messageSticker.emoji
|
||||
)
|
||||
else {
|
||||
throw OWSAssertionError("Invalid sticker.")
|
||||
}
|
||||
let stickerMetadata = attachmentStream.attachmentStream.asStickerMetadata(
|
||||
stickerInfo: messageSticker.info,
|
||||
stickerType: StickerManager.stickerType(forContentType: attachmentStream.attachment.mimeType),
|
||||
emojiString: messageSticker.emoji
|
||||
)
|
||||
self.sticker = .available(
|
||||
stickerMetadata: stickerMetadata,
|
||||
attachmentStream: attachmentStream
|
||||
|
||||
@ -20,9 +20,6 @@ public class CVComponentSticker: CVComponentBase, CVComponent {
|
||||
private var attachmentPointer: ReferencedAttachmentPointer? {
|
||||
sticker.attachmentPointer
|
||||
}
|
||||
private var stickerInfo: StickerInfo? {
|
||||
stickerMetadata?.stickerInfo
|
||||
}
|
||||
|
||||
init(itemModel: CVItemModel, sticker: CVComponentState.Sticker) {
|
||||
self.sticker = sticker
|
||||
|
||||
@ -82,8 +82,9 @@ public class MessageStickerManagerImpl: MessageStickerManager {
|
||||
tx: DBWriteTransaction
|
||||
) throws -> OwnedAttachmentBuilder<Void> {
|
||||
do {
|
||||
// If the content type is missing or generic, assume it's a webp.
|
||||
let proto: SSKProtoAttachmentPointer
|
||||
if dataProto.contentType == MimeType.applicationOctetStream.rawValue {
|
||||
if dataProto.contentType == nil || dataProto.contentType == MimeType.applicationOctetStream.rawValue {
|
||||
let builder = dataProto.asBuilder()
|
||||
builder.setContentType(MimeType.imageWebp.rawValue)
|
||||
proto = builder.buildInfallibly()
|
||||
|
||||
@ -11,7 +11,7 @@ extension AttachmentStream {
|
||||
stickerInfo: StickerInfo,
|
||||
stickerType: StickerType,
|
||||
emojiString: String?
|
||||
) -> (any StickerMetadata)? {
|
||||
) -> any StickerMetadata {
|
||||
return EncryptedStickerMetadata.from(
|
||||
attachment: self,
|
||||
stickerInfo: stickerInfo,
|
||||
|
||||
@ -9,7 +9,6 @@ public protocol CVItemViewModel: AnyObject {
|
||||
var interaction: TSInteraction { get }
|
||||
var contactShare: ContactShareViewModel? { get }
|
||||
var linkPreview: OWSLinkPreview? { get }
|
||||
var stickerInfo: StickerInfo? { get }
|
||||
var stickerAttachment: AttachmentStream? { get }
|
||||
var stickerMetadata: (any StickerMetadata)? { get }
|
||||
var isGiftBadge: Bool { get }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user