2018-08-26 18:49:22 +00:00
|
|
|
//
|
|
|
|
// StatusContentLabel.swift
|
|
|
|
// Tusker
|
|
|
|
//
|
2018-08-28 01:27:34 +00:00
|
|
|
// Created by Shadowfacts on 8/27/18.
|
2018-08-26 18:49:22 +00:00
|
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
2018-09-11 14:52:21 +00:00
|
|
|
import Pachyderm
|
2018-08-26 18:49:22 +00:00
|
|
|
|
2018-08-28 01:27:34 +00:00
|
|
|
class StatusContentLabel: HTMLContentLabel {
|
2018-08-26 18:49:22 +00:00
|
|
|
|
2018-09-18 01:57:46 +00:00
|
|
|
var statusID: String! {
|
2018-08-27 16:40:22 +00:00
|
|
|
didSet {
|
|
|
|
text = status.content
|
|
|
|
}
|
|
|
|
}
|
2018-09-18 01:57:46 +00:00
|
|
|
var status: Status! {
|
|
|
|
return StatusCache.get(id: statusID)
|
|
|
|
}
|
2018-08-27 16:40:22 +00:00
|
|
|
|
2018-08-28 01:27:34 +00:00
|
|
|
override func getMention(for url: URL, text: String) -> Mention? {
|
2018-08-27 16:40:22 +00:00
|
|
|
return status.mentions.first(where: { mention -> Bool in
|
2018-09-11 14:52:21 +00:00
|
|
|
(text.dropFirst() == mention.username || text == mention.username) && url.host == mention.url.host
|
2018-08-28 01:27:34 +00:00
|
|
|
}) ?? super.getMention(for: url, text: text)
|
2018-08-27 16:40:22 +00:00
|
|
|
}
|
|
|
|
|
2018-09-11 14:52:21 +00:00
|
|
|
override func getTag(for url: URL, text: String) -> Hashtag? {
|
|
|
|
if let tag = status.hashtags.first(where: { $0.url == url }) {
|
2018-08-27 16:40:22 +00:00
|
|
|
return tag
|
|
|
|
} else {
|
2018-08-28 01:27:34 +00:00
|
|
|
return super.getTag(for: url, text: text)
|
2018-08-26 19:19:54 +00:00
|
|
|
}
|
2018-08-26 18:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|