From 2097758b9b0bcedabdc0d7916c4d7613f8f0e2b7 Mon Sep 17 00:00:00 2001 From: Siyu Yue Date: Tue, 20 Dec 2022 14:12:21 -0800 Subject: [PATCH] Fix layout call --- Sources/ListCellController.swift | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Sources/ListCellController.swift b/Sources/ListCellController.swift index f3dd7ee..2bff270 100644 --- a/Sources/ListCellController.swift +++ b/Sources/ListCellController.swift @@ -43,8 +43,7 @@ open class ListCellController< } private var updatingViewModel = false - private var invalidatingLayout = false - private var didUpdateCellWhenInvalidatingLayout = false + private var didLayoutSubiewsWhenInvalidatingLayout = false required public init( viewModel: ListViewModel, @@ -146,13 +145,10 @@ open class ListCellController< } override func cellDidLayoutSubviews() { - if invalidatingLayout { - updateCell(shouldInvalidateLayout: false) - didUpdateCellWhenInvalidatingLayout = true - } guard let cell = cell else { return } + didLayoutSubiewsWhenInvalidatingLayout = true cellDidLayoutSubviews(cell: cell as! ListCellType) } @@ -160,17 +156,13 @@ open class ListCellController< guard let cell = cell else { return } + didLayoutSubiewsWhenInvalidatingLayout = false if shouldInvalidateLayout { - invalidatingLayout = true - didUpdateCellWhenInvalidatingLayout = false layoutInvalidateHandler?(cell) - invalidatingLayout = false - - if !didUpdateCellWhenInvalidatingLayout { - configureCell(cell: cell as! ListCellType) - } - } else { - configureCell(cell: cell as! ListCellType) + } + configureCell(cell: cell as! ListCellType) + if !didLayoutSubiewsWhenInvalidatingLayout { + cellDidLayoutSubviews(cell: cell as! ListCellType) } } }