diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index eadaeddd0f..32bfabb7d5 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -364,11 +364,7 @@ BOOL gIsFirstMyPositionMode = YES; - (void)openMigration { [self performSegueWithIdentifier:kMigrationSegue sender:self]; } - (void)openBookmarks { - auto const & ids = GetFramework().GetBookmarkManager().GetBmGroupsIdList(); - BOOL const oneCategory = (ids.size() == 1); - auto vc = oneCategory ? [[BookmarksVC alloc] initWithCategory:(ids.front())] - : [[BMCViewController alloc] init]; - [self.navigationController pushViewController:vc animated:YES]; + [self.navigationController pushViewController:[[BMCViewController alloc] init] animated:YES]; } - (void)openMapsDownloader:(MWMMapDownloaderMode)mode diff --git a/iphone/Maps/Common/Statistics/Statistics.mm b/iphone/Maps/Common/Statistics/Statistics.mm index 773a05d586..b8bbb0990e 100644 --- a/iphone/Maps/Common/Statistics/Statistics.mm +++ b/iphone/Maps/Common/Statistics/Statistics.mm @@ -63,7 +63,9 @@ void checkFlurryLogStatus(FlurryEventRecordStatus status) return; NSMutableDictionary * params = [self addDefaultAttributesToParameters:parameters]; [Alohalytics logEvent:eventName withDictionary:params]; - checkFlurryLogStatus([Flurry logEvent:eventName withParameters:params]); + dispatch_async(dispatch_get_main_queue(), ^{ + checkFlurryLogStatus([Flurry logEvent:eventName withParameters:params]); + }); } - (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters atLocation:(CLLocation *)location @@ -74,7 +76,9 @@ void checkFlurryLogStatus(FlurryEventRecordStatus status) [Alohalytics logEvent:eventName withDictionary:params atLocation:location]; auto const & coordinate = location ? location.coordinate : kCLLocationCoordinate2DInvalid; params[kStatLocation] = makeLocationEventValue(coordinate.latitude, coordinate.longitude); - checkFlurryLogStatus([Flurry logEvent:eventName withParameters:params]); + dispatch_async(dispatch_get_main_queue(), ^{ + checkFlurryLogStatus([Flurry logEvent:eventName withParameters:params]); + }); } - (NSMutableDictionary *)addDefaultAttributesToParameters:(NSDictionary *)parameters diff --git a/iphone/Maps/Core/Bookmarks/MWMBookmarksManager.mm b/iphone/Maps/Core/Bookmarks/MWMBookmarksManager.mm index 8adec6f92d..c7ee83a1aa 100644 --- a/iphone/Maps/Core/Bookmarks/MWMBookmarksManager.mm +++ b/iphone/Maps/Core/Bookmarks/MWMBookmarksManager.mm @@ -189,6 +189,8 @@ using TLoopBlock = void (^)(Observer observer); + (NSDate *)lastSynchronizationDate { auto timestampInMs = GetFramework().GetBookmarkManager().GetLastSynchronizationTimestampInMs(); + if (timestampInMs == 0) + return nil; return [NSDate dateWithTimeIntervalSince1970:timestampInMs / 1000]; } diff --git a/map/cloud.cpp b/map/cloud.cpp index 28d786c5af..6e0c586adb 100644 --- a/map/cloud.cpp +++ b/map/cloud.cpp @@ -615,7 +615,6 @@ void Cloud::FinishUploading(SynchronizationResult result, std::string const & er SaveIndexImpl(); } - if (m_onSynchronizationFinished != nullptr) m_onSynchronizationFinished(result, errorStr); } diff --git a/map/user.cpp b/map/user.cpp index a269c01f58..ceee100f15 100644 --- a/map/user.cpp +++ b/map/user.cpp @@ -212,10 +212,10 @@ void User::Authenticate(std::string const & socialToken, SocialTokenType socialT Request(url, nullptr, [this](std::string const & response) { SetAccessToken(ParseAccessToken(response)); - FinishAuthentication(!m_accessToken.empty()); - }, [this](int code) + FinishAuthentication(); + }, [this](int) { - FinishAuthentication(false /* success */); + FinishAuthentication(); }); }); } @@ -229,21 +229,12 @@ bool User::StartAuthentication() return true; } -void User::FinishAuthentication(bool success) +void User::FinishAuthentication() { std::lock_guard lock(m_mutex); m_authenticationInProgress = false; - for (auto & s : m_subscribers) - { - if (s->m_onAuthenticate != nullptr) - { - s->m_onAuthenticate(success); - if (s->m_postCallAction == Subscriber::Action::RemoveSubscriber) - s.reset(); - } - } - ClearSubscribersImpl(); + NotifySubscribersImpl(); } void User::AddSubscriber(std::unique_ptr && subscriber) @@ -251,9 +242,15 @@ void User::AddSubscriber(std::unique_ptr && subscriber) std::lock_guard lock(m_mutex); if (subscriber->m_onChangeToken != nullptr) + { subscriber->m_onChangeToken(m_accessToken); - if (subscriber->m_postCallAction == Subscriber::Action::RemoveSubscriber) + if (subscriber->m_postCallAction != Subscriber::Action::RemoveSubscriber) + m_subscribers.push_back(std::move(subscriber)); + } + else + { m_subscribers.push_back(std::move(subscriber)); + } } void User::ClearSubscribers() @@ -267,11 +264,11 @@ void User::NotifySubscribersImpl() for (auto & s : m_subscribers) { if (s->m_onChangeToken != nullptr) - { s->m_onChangeToken(m_accessToken); - if (s->m_postCallAction == Subscriber::Action::RemoveSubscriber) - s.reset(); - } + if (s->m_onAuthenticate != nullptr) + s->m_onAuthenticate(!m_accessToken.empty()); + if (s->m_postCallAction == Subscriber::Action::RemoveSubscriber) + s.reset(); } ClearSubscribersImpl(); } diff --git a/map/user.hpp b/map/user.hpp index ab82b6bfc2..7781d3680d 100644 --- a/map/user.hpp +++ b/map/user.hpp @@ -78,7 +78,7 @@ private: void ClearSubscribersImpl(); bool StartAuthentication(); - void FinishAuthentication(bool success); + void FinishAuthentication(); std::string m_accessToken; mutable std::mutex m_mutex;