diff --git a/Tusker/Screens/Notifications/ActionNotificationGroupCollectionViewCell.swift b/Tusker/Screens/Notifications/ActionNotificationGroupCollectionViewCell.swift index da79272e..2a11af32 100644 --- a/Tusker/Screens/Notifications/ActionNotificationGroupCollectionViewCell.swift +++ b/Tusker/Screens/Notifications/ActionNotificationGroupCollectionViewCell.swift @@ -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 { diff --git a/Tusker/Views/MultiSourceEmojiLabel.swift b/Tusker/Views/MultiSourceEmojiLabel.swift index 1b682121..e6978801 100644 --- a/Tusker/Views/MultiSourceEmojiLabel.swift +++ b/Tusker/Views/MultiSourceEmojiLabel.swift @@ -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) } } }