Support instance with malformed statuses URL

This commit is contained in:
Thomas Ricouard 2023-01-18 13:36:00 +01:00
parent 1b9d4e0247
commit d737b429b4
5 changed files with 7 additions and 7 deletions

View File

@ -43,7 +43,7 @@ public protocol AnyStatus {
var pinned: Bool? { get }
var bookmarked: Bool? { get }
var emojis: [Emoji] { get }
var url: URL? { get }
var url: String? { get }
var application: Application? { get }
var inReplyToAccountId: String? { get }
var visibility: Visibility { get }
@ -76,7 +76,7 @@ public struct Status: AnyStatus, Codable, Identifiable {
public let pinned: Bool?
public let bookmarked: Bool?
public let emojis: [Emoji]
public let url: URL?
public let url: String?
public let application: Application?
public let inReplyToAccountId: String?
public let visibility: Visibility
@ -141,7 +141,7 @@ public struct ReblogStatus: AnyStatus, Codable, Identifiable {
public let pinned: Bool?
public let bookmarked: Bool?
public let emojis: [Emoji]
public let url: URL?
public let url: String?
public var application: Application?
public let inReplyToAccountId: String?
public let visibility: Visibility

View File

@ -69,7 +69,7 @@ public class StatusEditorViewModel: ObservableObject {
private var currentSuggestionRange: NSRange?
private var embeddedStatusURL: URL? {
return embeddedStatus?.reblog?.url ?? embeddedStatus?.url
return URL(string: embeddedStatus?.reblog?.url ?? embeddedStatus?.url ?? "")
}
private var uploadTask: Task<Void, Never>?

View File

@ -63,7 +63,7 @@ struct StatusRowContextMenu: View {
}
}
if let url = viewModel.status.reblog?.url ?? viewModel.status.url {
if let url = URL(string: viewModel.status.reblog?.url ?? viewModel.status.url ?? "") {
Button { openURL(url) } label: {
Label("View in Browser", systemImage: "safari")
}

View File

@ -230,7 +230,7 @@ public struct StatusRowView: View {
}
}
if let card = status.card,
viewModel.embeddedStatus?.url != status.card?.url,
viewModel.embeddedStatus?.url != status.card?.url.absoluteString,
status.mediaAttachments.isEmpty,
!viewModel.isEmbedLoading,
theme.statusDisplayStyle == .large

View File

@ -61,7 +61,7 @@ public class StatusRowViewModel: ObservableObject {
func navigateToDetail(routerPath: RouterPath) {
guard !isFocused else { return }
if isRemote, let url = status.reblog?.url ?? status.url {
if isRemote, let url = URL(string: status.reblog?.url ?? status.url ?? "") {
routerPath.navigate(to: .remoteStatusDetail(url: url))
} else {
routerPath.navigate(to: .statusDetail(id: status.reblog?.id ?? status.id))