Fix mentions from Misskey opening browser instead of profile view
This commit is contained in:
parent
9c0c1f87f8
commit
7d66117fab
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue