From 2dbdb46f10174f5f8e8ca7f1d8b97906486f20bb Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 17:55:36 +0000 Subject: [PATCH] Bugfix FXIOS-7498 [v119] Crash when adding icon to sync now setting (#17151) (#17176) * Bugfix FXIOS-7498 [v121] Crash when adding icon to sync now setting (#16644) * addressed PR comments --------- Co-authored-by: Stefan Vladut (cherry picked from commit e76a521d689c1b1e2d081f022900aa0ddd4bc577) Co-authored-by: petruSt24 <126153378+petruSt24@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- .../Settings/Main/Account/SyncNowSetting.swift | 10 ++++++---- .../Settings/SettingsTableViewController.swift | 9 ++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Client/Frontend/Settings/Main/Account/SyncNowSetting.swift b/Client/Frontend/Settings/Main/Account/SyncNowSetting.swift index 6100be319488..4ad94fa26357 100644 --- a/Client/Frontend/Settings/Main/Account/SyncNowSetting.swift +++ b/Client/Frontend/Settings/Main/Account/SyncNowSetting.swift @@ -239,10 +239,12 @@ class SyncNowSetting: WithAccountSetting { } private func addAccessoryView(with image: UIImageView, to cell: UITableViewCell) { - accessoryViewContainer.addArrangedSubview(image) - accessoryViewContainer.addArrangedSubview(troubleshootButton) - - cell.accessoryView = accessoryViewContainer + DispatchQueue.main.async { [weak self] in + guard let troubleshootButton = self?.troubleshootButton else { return } + self?.accessoryViewContainer.addArrangedSubview(image) + self?.accessoryViewContainer.addArrangedSubview(troubleshootButton ) + cell.accessoryView = self?.accessoryViewContainer + } } override func onClick(_ navigationController: UINavigationController?) { diff --git a/Client/Frontend/Settings/SettingsTableViewController.swift b/Client/Frontend/Settings/SettingsTableViewController.swift index 49249112f6ef..1c8a8ee2053c 100644 --- a/Client/Frontend/Settings/SettingsTableViewController.swift +++ b/Client/Frontend/Settings/SettingsTableViewController.swift @@ -830,12 +830,19 @@ class SettingsTableViewController: ThemedTableViewController { if let setting = section[indexPath.row] { let cell = dequeueCellFor(indexPath: indexPath, setting: setting) setting.onConfigureCell(cell, theme: themeManager.currentTheme) - cell.applyTheme(theme: themeManager.currentTheme) return cell } return super.tableView(tableView, cellForRowAt: indexPath) } + override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { + let section = settings[indexPath.section] + if let setting = section[indexPath.row], let themedCell = cell as? ThemedTableViewCell { + setting.onConfigureCell(themedCell, theme: themeManager.currentTheme) + themedCell.applyTheme(theme: themeManager.currentTheme) + } + } + private func dequeueCellFor(indexPath: IndexPath, setting: Setting) -> ThemedTableViewCell { if setting.style == .subtitle { guard let cell = tableView.dequeueReusableCell(withIdentifier: ThemedSubtitleTableViewCell.cellIdentifier, for: indexPath) as? ThemedSubtitleTableViewCell else {