From 525f0f8f0abbb84d8184dac91f616181edd827f6 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Fri, 28 Jun 2024 09:13:49 -0400 Subject: [PATCH 1/3] Digital PCT265 defect CXTDT-579049: Add indexing safety to track action call. --- MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index 3ef117da..fc79b5bd 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -361,7 +361,7 @@ open class Carousel: View { } func trackSwipeActionAnalyticsforIndex(_ index : Int){ - guard let itemModel = molecules?[index], + guard let itemModel = molecules?[safe:index], let viewControllerObject = delegateObject?.moleculeDelegate as? MVMCoreViewControllerProtocol else { return } MVMCoreUILoggingHandler.shared()?.defaultLogAction(forController: viewControllerObject, actionInformation: itemModel.toJSON(), additionalData: nil) } From 080f77581f6d48a4cc21a646cd481bc7e7c5ff64 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Fri, 28 Jun 2024 09:18:13 -0400 Subject: [PATCH 2/3] Digital PCT265 defect CXTDT-579049: Fix indexing safety to mocules to add. (Another crash in App Store reports.) --- MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift index 943f53ad..22ec9bcd 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsListItemModel.swift @@ -108,8 +108,7 @@ extension TabsListItemModel: AddMolecules { public func moleculesToAdd() -> AddMolecules.AddParameters? { guard addedMolecules == nil else { return nil } let index = tabs.selectedIndex - guard molecules.count >= index else { return nil } - let addedMolecules = molecules[index] + guard let addedMolecules = molecules[safe: index] else { return nil } self.addedMolecules = addedMolecules return (addedMolecules, .below) } From 91eb4fa87a793c141c22563a9540e541460f37e9 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Fri, 28 Jun 2024 15:23:17 -0400 Subject: [PATCH 3/3] Digital PCT265 defect CXTDT-579050: Prevent updateViews from triggering tableView(_:cellForRowAt:) through visibleCells. --- .../ThreeLayerTableViewController.swift | 4 ++-- MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift index 4bd889bd..c85e7b85 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift @@ -52,8 +52,8 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController, Rotor bottomView.updateView(width) showFooter(width) } - tableView.visibleCells.forEach { cell in - (cell as? MVMCoreViewProtocol)?.updateView(width) + MVMCoreUIUtility.findParentViews(by: (UITableViewCell & MVMCoreViewProtocol).self, views: tableView.subviews).forEach { view in + view.updateView(width) } } diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift b/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift index ea91f62b..5b70412e 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift +++ b/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift @@ -60,6 +60,16 @@ public extension MVMCoreUIUtility { return findViews(by: type, views: queue, excludedViews: excludedViews) + matching } + static func findParentViews(by type: T.Type, views: [UIView]) -> [T] { + return views.reduce(into: [T]()) { matchingViews, view in + if let view = view as? T { + return matchingViews.append(view) // If this view is the type stop here and return, ignoring its children. + } + // Otherwise check downstream. + matchingViews += findParentViews(by: type, views: view.subviews) + } + } + @MainActor static func visibleNavigationBarStlye() -> NavigationItemStyle? { if let navController = NavigationController.navigationController(),