Skip to content

Commit

Permalink
Prevent the homescreen from resetting on every appearance.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Mar 21, 2022
1 parent d10c387 commit 281915f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
26 changes: 2 additions & 24 deletions Riot/Modules/Home/HomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,11 @@ - (void)viewWillAppear:(BOOL)animated

[AppDelegate theDelegate].masterTabBarController.tabBar.tintColor = ThemeService.shared.theme.tintColor;

if (recentsDataSource)
if (recentsDataSource.recentsDataSourceMode != RecentsDataSourceModeHome)
{
// Take the lead on the shared data source.
[recentsDataSource setDelegate:self andRecentsDataSourceMode:RecentsDataSourceModeHome];
}

[self moveAllCollectionsToLeft];
}
}

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
Expand All @@ -133,26 +131,6 @@ - (void)destroy
[super destroy];
}

- (void)moveAllCollectionsToLeft
{
selectedCollectionViewContentOffset = -1;

// Scroll all rooms collections to their beginning
for (NSInteger section = 0; section < [self numberOfSectionsInTableView:self.recentsTableView]; section++)
{
UITableViewCell *firstSectionCell = [self.recentsTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:section]];
if (firstSectionCell && [firstSectionCell isKindOfClass:TableViewCellWithCollectionView.class])
{
TableViewCellWithCollectionView *tableViewCell = (TableViewCellWithCollectionView*)firstSectionCell;

if ([tableViewCell.collectionView numberOfItemsInSection:0] > 0)
{
[tableViewCell.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionLeft animated:NO];
}
}
}
}

- (SecureBackupBannerCell *)secureBackupBannerPrototypeCell
{
if (!_secureBackupBannerPrototypeCell)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ - (void)viewWillAppear:(BOOL)animated

// Observe the server sync
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSyncNotification) name:kMXSessionDidSyncNotification object:nil];

// Do a full reload
[self refreshRecentsTable];
}

- (void)viewWillDisappear:(BOOL)animated
Expand All @@ -180,12 +177,6 @@ - (void)viewWillDisappear:(BOOL)animated

// The user may still press search button whereas the view disappears
ignoreSearchRequest = YES;

// Leave potential search session
if (!self.recentsSearchBar.isHidden)
{
[self searchBarCancelButtonClicked:self.recentsSearchBar];
}

[[NSNotificationCenter defaultCenter] removeObserver:self name:kMXKRoomDataSourceSyncStatusChanged object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:kMXSessionDidSyncNotification object:nil];
Expand Down

0 comments on commit 281915f

Please sign in to comment.