A WIP iOS app for Mastodon and Pleroma.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
969 B

//
// StatusContentLabel.swift
// Tusker
//
// Created by Shadowfacts on 8/27/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import UIKit
import Pachyderm
class StatusContentLabel: HTMLContentLabel {
var statusID: String! {
didSet {
text = status.content
}
}
var status: Status! {
return StatusCache.get(id: statusID)
}
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 == mention.url.host
}) ?? super.getMention(for: url, text: text)
}
override func getTag(for url: URL, text: String) -> Hashtag? {
if let tag = status.hashtags.first(where: { $0.url == url }) {
return tag
} else {
return super.getTag(for: url, text: text)
}
}
}