// // StatusContentLabel.swift // Tusker // // Created by Shadowfacts on 8/27/18. // Copyright © 2018 Shadowfacts. All rights reserved. // import UIKit import MastodonKit class StatusContentLabel: HTMLContentLabel { var status: Status! { didSet { text = status.content } } override func getMention(for url: URL, text: String) -> Mention? { return status.mentions.first(where: { mention -> Bool in (text.dropFirst() == mention.username || text == mention.username) && url.host == URL(string: mention.url)!.host }) ?? super.getMention(for: url, text: text) } override func getTag(for url: URL, text: String) -> MastodonKit.Tag? { if let tag = status.tags.first(where: { tag -> Bool in tag.url == url.absoluteString }) { return tag } else { return super.getTag(for: url, text: text) } } }