Tusker/Tusker/Views/StatusContentLabel.swift

38 lines
969 B
Swift

//
// 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)
}
}
}