Fix mentions from Misskey opening browser instead of profile view

This commit is contained in:
Shadowfacts 2022-10-10 14:31:26 -04:00
parent 9c0c1f87f8
commit 7d66117fab
2 changed files with 7 additions and 4 deletions

View File

@ -9,14 +9,14 @@
import Foundation
import WebURL
public class Mention: Codable {
public struct Mention: Codable {
public let url: WebURL
public let username: String
public let acct: String
/// The instance-local ID of the user being mentioned.
public let id: String
public required init(from decoder: Decoder) throws {
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.username = try container.decode(String.self, forKey: .username)
self.acct = try container.decode(String.self, forKey: .acct)

View File

@ -26,8 +26,11 @@ class StatusContentTextView: ContentTextView {
let mastodonController = mastodonController,
let status = mastodonController.persistentContainer.status(for: statusID) {
mention = status.mentions.first { (mention) in
// Mastodon and Pleroma include the @ in the <a> text, GNU Social does not
(text.dropFirst() == mention.username || text == mention.username) && url.host == mention.url.host!.serialized
url.host == mention.url.host!.serialized && (
text.dropFirst() == mention.username // Mastodon and Pleroma include @ in the text
|| text.dropFirst() == mention.acct // Misskey includes @ and uses the whole acct
|| text == mention.username // GNU Social does not include the @ in the text, so we don't need to drop it
)
}
} else {
mention = nil