my fork of the bluesky client

Fix Retain Cycles in SheetViewController (#6202)

* Fix retain cycle in SheetViewController.swift

* Fix retain cycles

authored by

Hazem Ali and committed by
GitHub
9a10af71 b4412f33

+8 -5
+8 -5
modules/bottom-sheet/ios/SheetViewController.swift
··· 64 64 65 65 func updateDetents(contentHeight: CGFloat, preventExpansion: Bool) { 66 66 if let sheet = self.sheetPresentationController { 67 - sheet.animateChanges { 68 - self.setDetents(contentHeight: contentHeight, preventExpansion: preventExpansion) 69 - if #available(iOS 16.0, *) { 70 - sheet.invalidateDetents() 71 - } 67 + // Capture `self` weakly to prevent retain cycles. 68 + // Also, capture `sheet` weakly to avoid potential strong references held by animateChanges. 69 + sheet.animateChanges { [weak self, weak sheet] in 70 + guard let weakSelf = self, let weakSheet = sheet else { return } 71 + weakSelf.setDetents(contentHeight: contentHeight, preventExpansion: preventExpansion) 72 + if #available(iOS 16.0, *) { 73 + weakSheet.invalidateDetents() 74 + } 72 75 } 73 76 } 74 77 }