forked from organicmaps/organicmaps
[ios] Remove bookmark model from observer list.
This commit is contained in:
parent
f3c23d20a2
commit
c2497f5565
3 changed files with 26 additions and 1 deletions
|
@ -42,8 +42,20 @@ final class BMCViewController: MWMViewController {
|
|||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
// Disable all notifications in BM on appearance of this view.
|
||||
// It allows to significantly improve performance in case of bookmarks
|
||||
// modification. All notifications will be sent on controller's disappearance.
|
||||
viewModel.setNotificationsEnabled(false)
|
||||
viewModel.addToObserverList()
|
||||
viewModel.convertAllKMLIfNeeded()
|
||||
}
|
||||
|
||||
override func viewDidDisappear(_ animated: Bool) {
|
||||
super.viewDidDisappear(animated)
|
||||
// Allow to send all notifications in BM.
|
||||
viewModel.setNotificationsEnabled(true)
|
||||
viewModel.removeFromObserverList()
|
||||
}
|
||||
|
||||
private func updateCategoryName(category: BMCCategory?) {
|
||||
let isNewCategory = (category == nil)
|
||||
|
|
|
@ -25,7 +25,6 @@ final class BMCDefaultViewModel: NSObject {
|
|||
|
||||
override init() {
|
||||
super.init()
|
||||
BM.add(self)
|
||||
loadData()
|
||||
}
|
||||
|
||||
|
@ -207,6 +206,14 @@ extension BMCDefaultViewModel: BMCViewModel {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func addToObserverList() {
|
||||
BM.add(self)
|
||||
}
|
||||
|
||||
func removeFromObserverList() {
|
||||
BM.remove(self)
|
||||
}
|
||||
}
|
||||
|
||||
extension BMCDefaultViewModel: MWMBookmarksObserver {
|
||||
|
|
|
@ -42,4 +42,10 @@ protocol BMCViewModel: AnyObject {
|
|||
func grant(permission: BMCPermission?)
|
||||
|
||||
func convertAllKMLIfNeeded();
|
||||
|
||||
func addToObserverList()
|
||||
func removeFromObserverList()
|
||||
|
||||
func setNotificationsEnabled(_ enabled: Bool)
|
||||
func areNotificationsEnabled() -> Bool
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue