Skip to content

Commit f0c4bfa

Browse files
authored
[Stats Revamp] Fix crash after backgrounding app from Stats screen (#20008)
* Avoid NSAttributedString crashing the app when it's being initialized in the background * Don't rebuild guide view when the app is in the background
1 parent 3333390 commit f0c4bfa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

WordPress/Classes/ViewRelated/Stats/Insights/StatsTotalInsightsCell.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ class StatsTotalInsightsCell: StatsBaseCell {
269269

270270
// Rebuilds guide view for accessibility only if guide view already exists
271271
private func rebuildGuideViewIfNeeded() {
272+
/// NSAttributedString initialized with HTML on the background crashes the app
273+
/// This method can be called when traitCollectionDidChange which can be triggered when app goes to background
274+
guard UIApplication.shared.applicationState != .background else {
275+
return
276+
}
277+
272278
if guideText != nil,
273279
let statsSummaryType = statsSummaryType,
274280
let guideText = StatsTotalInsightsData.makeTotalInsightsGuideText(lastPostInsight: lastPostInsight, statsSummaryType: statsSummaryType) {

0 commit comments

Comments
 (0)