Fix timeline failing to load because status card URL is invalid Fix #209

This commit is contained in:
Thomas Ricouard 2023-01-21 12:13:20 +01:00
parent 87471ed9c8
commit 77c94e940a
3 changed files with 9 additions and 9 deletions

View File

@ -2,10 +2,10 @@ import Foundation
public struct Card: Codable, Identifiable {
public var id: String {
url.absoluteString
url
}
public let url: URL
public let url: String
public let title: String?
public let description: String?
public let type: String

View File

@ -14,7 +14,7 @@ public struct StatusCardView: View {
}
public var body: some View {
if let title = card.title {
if let title = card.title, let url = URL(string: card.url) {
VStack(alignment: .leading) {
if let imageURL = card.image {
LazyImage(url: imageURL) { state in
@ -41,7 +41,7 @@ public struct StatusCardView: View {
.foregroundColor(.gray)
.lineLimit(3)
}
Text(card.url.host() ?? card.url.absoluteString)
Text(url.host() ?? url.absoluteString)
.font(.scaledFootnote)
.foregroundColor(theme.tintColor)
.lineLimit(1)
@ -57,18 +57,18 @@ public struct StatusCardView: View {
.stroke(.gray.opacity(0.35), lineWidth: 1)
)
.onTapGesture {
openURL(card.url)
openURL(url)
}
.contextMenu {
ShareLink(item: card.url) {
ShareLink(item: url) {
Label("Share this link", systemImage: "square.and.arrow.up")
}
Button { openURL(card.url) } label: {
Button { openURL(url) } label: {
Label("status.action.view-in-browser", systemImage: "safari")
}
Divider()
Button {
UIPasteboard.general.url = card.url
UIPasteboard.general.url = url
} label: {
Label("Copy link", systemImage: "doc.on.doc")
}

View File

@ -301,7 +301,7 @@ public struct StatusRowView: View {
@ViewBuilder
private func makeCardView(status: AnyStatus) -> some View {
if let card = status.card,
viewModel.embeddedStatus?.url != status.card?.url.absoluteString,
viewModel.embeddedStatus?.url != status.card?.url,
status.mediaAttachments.isEmpty,
!viewModel.isEmbedLoading,
theme.statusDisplayStyle == .large