mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-09 15:55:26 +00:00
Fix timeline failing to load because status card URL is invalid Fix #209
This commit is contained in:
parent
87471ed9c8
commit
77c94e940a
3 changed files with 9 additions and 9 deletions
|
@ -2,10 +2,10 @@ import Foundation
|
||||||
|
|
||||||
public struct Card: Codable, Identifiable {
|
public struct Card: Codable, Identifiable {
|
||||||
public var id: String {
|
public var id: String {
|
||||||
url.absoluteString
|
url
|
||||||
}
|
}
|
||||||
|
|
||||||
public let url: URL
|
public let url: String
|
||||||
public let title: String?
|
public let title: String?
|
||||||
public let description: String?
|
public let description: String?
|
||||||
public let type: String
|
public let type: String
|
||||||
|
|
|
@ -14,7 +14,7 @@ public struct StatusCardView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
public var body: some 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) {
|
VStack(alignment: .leading) {
|
||||||
if let imageURL = card.image {
|
if let imageURL = card.image {
|
||||||
LazyImage(url: imageURL) { state in
|
LazyImage(url: imageURL) { state in
|
||||||
|
@ -41,7 +41,7 @@ public struct StatusCardView: View {
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
.lineLimit(3)
|
.lineLimit(3)
|
||||||
}
|
}
|
||||||
Text(card.url.host() ?? card.url.absoluteString)
|
Text(url.host() ?? url.absoluteString)
|
||||||
.font(.scaledFootnote)
|
.font(.scaledFootnote)
|
||||||
.foregroundColor(theme.tintColor)
|
.foregroundColor(theme.tintColor)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
|
@ -57,18 +57,18 @@ public struct StatusCardView: View {
|
||||||
.stroke(.gray.opacity(0.35), lineWidth: 1)
|
.stroke(.gray.opacity(0.35), lineWidth: 1)
|
||||||
)
|
)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
openURL(card.url)
|
openURL(url)
|
||||||
}
|
}
|
||||||
.contextMenu {
|
.contextMenu {
|
||||||
ShareLink(item: card.url) {
|
ShareLink(item: url) {
|
||||||
Label("Share this link", systemImage: "square.and.arrow.up")
|
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")
|
Label("status.action.view-in-browser", systemImage: "safari")
|
||||||
}
|
}
|
||||||
Divider()
|
Divider()
|
||||||
Button {
|
Button {
|
||||||
UIPasteboard.general.url = card.url
|
UIPasteboard.general.url = url
|
||||||
} label: {
|
} label: {
|
||||||
Label("Copy link", systemImage: "doc.on.doc")
|
Label("Copy link", systemImage: "doc.on.doc")
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,7 @@ public struct StatusRowView: View {
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private func makeCardView(status: AnyStatus) -> some View {
|
private func makeCardView(status: AnyStatus) -> some View {
|
||||||
if let card = status.card,
|
if let card = status.card,
|
||||||
viewModel.embeddedStatus?.url != status.card?.url.absoluteString,
|
viewModel.embeddedStatus?.url != status.card?.url,
|
||||||
status.mediaAttachments.isEmpty,
|
status.mediaAttachments.isEmpty,
|
||||||
!viewModel.isEmbedLoading,
|
!viewModel.isEmbedLoading,
|
||||||
theme.statusDisplayStyle == .large
|
theme.statusDisplayStyle == .large
|
||||||
|
|
Loading…
Reference in a new issue