From 7d66117fabc17baafc9db14a85a2f0b2b4682d54 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 10 Oct 2022 14:31:26 -0400 Subject: [PATCH] Fix mentions from Misskey opening browser instead of profile view --- Pachyderm/Sources/Pachyderm/Model/Mention.swift | 4 ++-- Tusker/Views/StatusContentTextView.swift | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Pachyderm/Sources/Pachyderm/Model/Mention.swift b/Pachyderm/Sources/Pachyderm/Model/Mention.swift index 49a58cc5..cde4c7a8 100644 --- a/Pachyderm/Sources/Pachyderm/Model/Mention.swift +++ b/Pachyderm/Sources/Pachyderm/Model/Mention.swift @@ -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) diff --git a/Tusker/Views/StatusContentTextView.swift b/Tusker/Views/StatusContentTextView.swift index d6eaa204..2db13a98 100644 --- a/Tusker/Views/StatusContentTextView.swift +++ b/Tusker/Views/StatusContentTextView.swift @@ -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 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