From 1247ac433da9f64cd118a97ba366287e4fb3611b Mon Sep 17 00:00:00 2001 From: VladiMihaylenko Date: Mon, 23 Apr 2018 14:31:50 +0300 Subject: [PATCH] [ios] Remove bookmark model from observer list. --- .../Bookmarks/Categories/BMCView/BMCViewController.swift | 5 ++--- .../Categories/BMCViewModel/BMCDefaultViewModel.swift | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift b/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift index eeac908c7b..b48e68e167 100644 --- a/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift +++ b/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift @@ -42,20 +42,19 @@ 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?) { diff --git a/iphone/Maps/Bookmarks/Categories/BMCViewModel/BMCDefaultViewModel.swift b/iphone/Maps/Bookmarks/Categories/BMCViewModel/BMCDefaultViewModel.swift index 5156111b2c..7c83985267 100644 --- a/iphone/Maps/Bookmarks/Categories/BMCViewModel/BMCDefaultViewModel.swift +++ b/iphone/Maps/Bookmarks/Categories/BMCViewModel/BMCDefaultViewModel.swift @@ -222,6 +222,14 @@ extension BMCDefaultViewModel: BMCViewModel { func areNotificationsEnabled() -> Bool { return BM.areNotificationsEnabled() } + + func addToObserverList() { + BM.add(self) + } + + func removeFromObserverList() { + BM.remove(self) + } } extension BMCDefaultViewModel: MWMBookmarksObserver {