Fix emojis getting set without setting emoji identifier
This commit is contained in:
parent
77c44c323f
commit
8a911f238b
|
@ -52,7 +52,7 @@ class FeaturedProfileCollectionViewCell: UICollectionViewCell {
|
|||
displayNameLabel.updateForAccountDisplayName(account: account)
|
||||
|
||||
noteTextView.setTextFromHtml(account.note)
|
||||
noteTextView.setEmojis(account.emojis)
|
||||
noteTextView.setEmojis(account.emojis, identifier: account.id)
|
||||
|
||||
avatarImageView.image = nil
|
||||
if let avatar = account.avatar {
|
||||
|
|
|
@ -24,6 +24,7 @@ extension BaseEmojiLabel {
|
|||
// blergh
|
||||
precondition(Thread.isMainThread)
|
||||
|
||||
emojiIdentifier = identifier
|
||||
emojiRequests.forEach { $0.cancel() }
|
||||
emojiRequests = []
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
|||
}
|
||||
|
||||
// MARK: - Emojis
|
||||
func setEmojis(_ emojis: [Emoji]) {
|
||||
replaceEmojis(in: attributedText!, emojis: emojis, identifier: emojiIdentifier) { attributedString, didReplaceEmojis in
|
||||
func setEmojis(_ emojis: [Emoji], identifier: String?) {
|
||||
replaceEmojis(in: attributedText!, emojis: emojis, identifier: identifier) { attributedString, didReplaceEmojis in
|
||||
guard didReplaceEmojis else {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -21,13 +21,9 @@ class EmojiLabel: UILabel, BaseEmojiLabel {
|
|||
func setEmojis(_ emojis: [Emoji], identifier: String) {
|
||||
guard emojis.count > 0, let attributedText = attributedText else { return }
|
||||
|
||||
self.emojiIdentifier = identifier
|
||||
emojiRequests.forEach { $0.cancel() }
|
||||
emojiRequests = []
|
||||
hasEmojis = true
|
||||
|
||||
replaceEmojis(in: attributedText.string, emojis: emojis, identifier: identifier) { [weak self] (newAttributedText, _) in
|
||||
replaceEmojis(in: attributedText.string, emojis: emojis, identifier: identifier) { [weak self] (newAttributedText, didReplaceEmojis) in
|
||||
guard let self = self, self.emojiIdentifier == identifier else { return }
|
||||
self.hasEmojis = didReplaceEmojis
|
||||
self.attributedText = newAttributedText
|
||||
self.setNeedsLayout()
|
||||
self.setNeedsDisplay()
|
||||
|
|
|
@ -110,7 +110,7 @@ class ProfileHeaderView: UIView {
|
|||
|
||||
noteTextView.navigationDelegate = delegate
|
||||
noteTextView.setTextFromHtml(account.note)
|
||||
noteTextView.setEmojis(account.emojis)
|
||||
noteTextView.setEmojis(account.emojis, identifier: account.id)
|
||||
|
||||
// don't show relationship label for the user's own account
|
||||
if accountID != mastodonController.account?.id {
|
||||
|
@ -148,7 +148,7 @@ class ProfileHeaderView: UIView {
|
|||
valueTextView.isSelectable = false
|
||||
valueTextView.font = .systemFont(ofSize: 17)
|
||||
valueTextView.setTextFromHtml(field.value)
|
||||
valueTextView.setEmojis(account.emojis)
|
||||
valueTextView.setEmojis(account.emojis, identifier: account.id)
|
||||
valueTextView.textAlignment = .left
|
||||
valueTextView.awakeFromNib()
|
||||
valueTextView.navigationDelegate = delegate
|
||||
|
|
|
@ -16,9 +16,8 @@ class StatusContentTextView: ContentTextView {
|
|||
|
||||
func setTextFrom(status: StatusMO) {
|
||||
statusID = status.id
|
||||
emojiIdentifier = status.id
|
||||
setTextFromHtml(status.content)
|
||||
setEmojis(status.emojis)
|
||||
setEmojis(status.emojis, identifier: status.id)
|
||||
}
|
||||
|
||||
override func getMention(for url: URL, text: String) -> Mention? {
|
||||
|
|
Loading…
Reference in New Issue