[iOS] Fixed place page bookmarks crash

This commit is contained in:
Zoia Pribytkova 2019-08-08 15:20:09 +03:00 committed by Aleksey Belousov
parent 28b454983b
commit 36d2e88292
3 changed files with 17 additions and 2 deletions

View file

@ -289,5 +289,6 @@ using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * d
+ (void)toggleCoordinateSystem;
- (void)reguestPromoCatalog:(platform::NetworkPolicy const &)canUseNetwork;
- (NSInteger)bookmarkSectionPosition;
@end

View file

@ -446,6 +446,14 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
});
}
- (NSInteger)bookmarkSectionPosition {
if (self.isPromoCatalog) {
return 2;
} else {
return 1;
}
}
#pragma mark - Update bookmark status
- (void)updateBookmarkStatus:(BOOL)isBookmark
@ -464,7 +472,12 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
auto editSession = bmManager.GetEditSession();
auto const * bookmark = editSession.CreateBookmark(std::move(bmData), categoryId);
f.FillBookmarkInfo(*bookmark, m_info);
m_sections.insert(m_sections.begin() + 1, Sections::Bookmark);
NSUInteger position = [self bookmarkSectionPosition];
if (self.isPromoCatalog) {
m_sections.insert(m_sections.begin() + position, Sections::Bookmark);
} else {
m_sections.insert(m_sections.begin() + position, Sections::Bookmark);
}
}
else
{

View file

@ -196,8 +196,9 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
if (!tv)
return;
[tv update:^{
NSUInteger const position = [data bookmarkSectionPosition];
auto set =
[NSIndexSet indexSetWithIndex:static_cast<NSInteger>(place_page::Sections::Bookmark)];
[NSIndexSet indexSetWithIndex:position];
if (isBookmark)
[tv insertSections:set withRowAnimation:UITableViewRowAnimationAutomatic];
else