Commit 09f0557e by Demid Merzlyakov

Fix occasional crash due to working with the UI from a background thread.

parent ef2c8a96
......@@ -8,6 +8,7 @@
import UIKit
import CoreLocation
import OneWeatherAnalytics
import OneWeatherCore
class TodayViewController: UIViewController {
//Private
......@@ -63,8 +64,10 @@ class TodayViewController: UIViewController {
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
coordinator.animate { _ in
self.tableView.reloadData()
onMain {
coordinator.animate { _ in
self.tableView.reloadData()
}
}
}
......@@ -82,7 +85,10 @@ private extension TodayViewController {
view.backgroundColor = ThemeManager.currentTheme.baseBackgroundColor
localizationObserver = NotificationCenter.default.addObserver(forName: .localizationChange, object: nil, queue: .main, using: { [weak self] _ in
self?.tableView.reloadData()
onMain {
self?.tableView.reloadData()
}
})
}
......@@ -176,10 +182,12 @@ extension TodayViewController: TodayViewModelDelegate {
}
func viewModelDidChange<P>(model: P) where P : ViewModelProtocol {
cityButton.configure(with: viewModel.location)
cityButton.isHidden = false
tableView.isHidden = false
tableView.reloadData()
onMain {
self.cityButton.configure(with: self.viewModel.location)
self.cityButton.isHidden = false
self.tableView.isHidden = false
self.tableView.reloadData()
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment