Files
session-ios/Session/Utilities/LinkPreview+Convenience.swift
Morgan Pretty 1b863fdf33 Finished off changes
• Linked up quote clearing
• Removed the duplicate link preview loading and UI from the MediaMessageView (just use the input UI now)
• Cleaned up how the InputView input types is handled a bit
• Fixed an issue where link previews weren't rendering in the share extension
2025-11-03 12:35:48 +11:00

32 lines
1.1 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import UIKit
import SessionUIKit
import SessionMessagingKit
import SessionUtilitiesKit
public extension LinkPreview {
func sentState(
imageAttachment: Attachment?,
using dependencies: Dependencies
) -> LinkPreviewViewModel {
return LinkPreviewViewModel(
state: .sent,
urlString: url,
title: (title?.isEmpty == false ? title : nil),
imageSource: {
/// **Note:** We don't check if the image is valid here because that can be confirmed in 'imageState' and it's a
/// little inefficient
guard
imageAttachment?.isImage == true,
let imageDownloadUrl: String = imageAttachment?.downloadUrl,
let path: String = try? dependencies[singleton: .attachmentManager]
.path(for: imageDownloadUrl)
else { return nil }
return .url(URL(fileURLWithPath: path))
}()
)
}
}