From e3c0b6cbed27f35907cb835baa02853df69f17a6 Mon Sep 17 00:00:00 2001 From: Sam Symons Date: Fri, 9 Feb 2024 07:35:28 -0800 Subject: [PATCH] Fix HomeViewController retain cycle (#2462) Task/Issue URL: https://app.asana.com/0/414235014887631/1206561582798187/f Tech Design URL: CC: Description: This PR fixes an issue with every HomeViewController instance being affected by a retain cycle. --- DuckDuckGo/HomeCollectionView.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo/HomeCollectionView.swift b/DuckDuckGo/HomeCollectionView.swift index 7d3a086e82..54a216ef30 100644 --- a/DuckDuckGo/HomeCollectionView.swift +++ b/DuckDuckGo/HomeCollectionView.swift @@ -85,8 +85,12 @@ class HomeCollectionView: UICollectionView { case .favorites: let renderer = FavoritesHomeViewSectionRenderer(viewModel: favoritesViewModel) - renderer.onFaviconMissing = { _ in - controller.faviconsFetcherOnboarding.presentOnboardingIfNeeded(from: controller) + renderer.onFaviconMissing = { [weak self] _ in + guard let self else { + return + } + + self.controller.faviconsFetcherOnboarding.presentOnboardingIfNeeded(from: self.controller) } renderers.install(renderer: renderer)