diff --git a/IceCubesApp/App/Tabs/Settings/SettingsTab.swift b/IceCubesApp/App/Tabs/Settings/SettingsTab.swift index 9751bea1..1458d841 100644 --- a/IceCubesApp/App/Tabs/Settings/SettingsTab.swift +++ b/IceCubesApp/App/Tabs/Settings/SettingsTab.swift @@ -35,7 +35,7 @@ struct SettingsTabs: View { } private var accountsSection: some View { - Section("Account") { + Section("Accounts") { ForEach(appAccountsManager.availableAccounts) { account in HStack { AppAccountView(viewModel: .init(appAccount: account)) diff --git a/Packages/Models/Sources/Models/Alias/HTMLString.swift b/Packages/Models/Sources/Models/Alias/HTMLString.swift index e04ec75c..4401bd9d 100644 --- a/Packages/Models/Sources/Models/Alias/HTMLString.swift +++ b/Packages/Models/Sources/Models/Alias/HTMLString.swift @@ -31,7 +31,7 @@ extension HTMLString { var ids: [Int] = [] for link in links { let href = try link.attr("href") - if href.contains(instance), + if href.contains(instance.lowercased()), let url = URL(string: href), let statusId = Int(url.lastPathComponent) { ids.append(statusId) @@ -47,8 +47,7 @@ extension HTMLString { do { // Add space between hashtags and mentions that follow each other let markdown = asMarkdown - .replacingOccurrences(of: ")[#", with: ") [#") - .replacingOccurrences(of: ")[@", with: ") [@") + .replacingOccurrences(of: ")[", with: ") [") let options = AttributedString.MarkdownParsingOptions(allowsExtendedAttributes: true, interpretedSyntax: .inlineOnlyPreservingWhitespace) return try AttributedString(markdown: markdown, options: options) diff --git a/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift b/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift index 157a33cb..1ce40f50 100644 --- a/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift +++ b/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift @@ -86,6 +86,14 @@ public class StatusEditorViewModel: ObservableObject { } } + func localURLforStatus(status: Status) -> URL? { + guard let server = client?.server else { return nil } + if status.url?.host == server.lowercased() { + return status.url + } + return URL(string: "https://\(server.lowercased())/@\(status.account.acct)/\(status.id)") + } + func prepareStatusText() { switch mode { case let .replyTo(status): @@ -99,7 +107,7 @@ public class StatusEditorViewModel: ObservableObject { mediasImages = status.mediaAttachments.map{ .init(image: nil, mediaAttachement: $0, error: nil )} case let .quote(status): self.embededStatus = status - if let url = status.reblog?.url ?? status.url { + if let url = localURLforStatus(status: status) { statusText = .init(string: "\n\nFrom: @\(status.reblog?.account.acct ?? status.account.acct)\n\(url)") selectedRange = .init(location: 0, length: 0) } @@ -148,7 +156,9 @@ public class StatusEditorViewModel: ObservableObject { } private func checkEmbed() { - if let embededStatus, !statusText.string.contains(embededStatus.reblog?.id ?? embededStatus.id) { + if let embededStatus, + let url = localURLforStatus(status: embededStatus), + !statusText.string.contains(url.absoluteString) { self.embededStatus = nil self.mode = .new }