Fix crash when action notification cell label leaks

This commit is contained in:
Shadowfacts 2023-05-14 18:24:21 -04:00
parent de53e0dcd6
commit 038e4b2e4e
2 changed files with 5 additions and 8 deletions

View File

@ -60,7 +60,7 @@ class ActionNotificationGroupCollectionViewCell: UICollectionViewListCell {
$0.adjustsFontForContentSizeCategory = true
$0.numberOfLines = 2
$0.lineBreakMode = .byTruncatingTail
$0.combiner = { [unowned self] in self.updateActionLabel(names: $0) }
$0.combiner = { [weak self] in self?.updateActionLabel(names: $0) ?? NSAttributedString() }
}
private let statusContentLabel = UILabel().configure {

View File

@ -24,21 +24,18 @@ class MultiSourceEmojiLabel: UILabel, BaseEmojiLabel {
var attributedStrings = pairs.map { NSAttributedString(string: $0.0) }
func recombine() {
if let combiner = self.combiner {
let recombine = { [weak self] in
if let self,
let combiner = self.combiner {
self.attributedText = combiner(attributedStrings)
}
}
recombine()
for (index, (string, emojis)) in pairs.enumerated() {
self.replaceEmojis(in: string, emojis: emojis, identifier: identifier) { (attributedString, _) in
attributedStrings[index] = attributedString
DispatchQueue.main.async { [weak self] in
guard let self else { return }
recombine()
}
DispatchQueue.main.async(execute: recombine)
}
}
}