diff --git a/Tusker/Views/Status/StatusCollectionViewCell.swift b/Tusker/Views/Status/StatusCollectionViewCell.swift index 5c2dae8d..61c93b9a 100644 --- a/Tusker/Views/Status/StatusCollectionViewCell.swift +++ b/Tusker/Views/Status/StatusCollectionViewCell.swift @@ -125,7 +125,19 @@ extension StatusCollectionViewCell { statusState.collapsed = false } } - collapseButton.isHidden = !statusState.collapsible! + let expected = !statusState.collapsible! + // Very very rarely, setting isHidden to false only seems to partially take effect: + // the button will be rendered, but isHidden will still return true, and the + // containing stack view won't have updated constraints for it and so the cell + // layout will be wrong and the button will overlap other views in the stack. + // So, as a truly cursed workaround, just try a few times in a row until reading + // back isHidden returns the correct value. + for _ in 0..<5 { + collapseButton.isHidden = expected + if collapseButton.isHidden == expected { + break + } + } contentContainer.setCollapsed(statusState.collapsed!) if statusState.collapsed! { contentContainer.alpha = 0