-
Notifications
You must be signed in to change notification settings - Fork 502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce the number of unnecessary home page reloads #5969
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
Riot/Modules/Common/Recents/Model/RecentsSectionUpdate.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -363,6 +363,7 @@ - (void)viewDidLayoutSubviews | |||||||||
|
||||||||||
- (void)refreshRecentsTable | ||||||||||
{ | ||||||||||
MXLogDebug(@"[RecentsViewController]: Refreshing recents table view") | ||||||||||
// Refresh the tabBar icon badges | ||||||||||
[[AppDelegate theDelegate].masterTabBarController refreshTabBarBadges]; | ||||||||||
|
||||||||||
|
@@ -1031,49 +1032,44 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac | |||||||||
|
||||||||||
- (void)dataSource:(MXKDataSource *)dataSource didCellChange:(id)changes | ||||||||||
{ | ||||||||||
BOOL cellReloaded = NO; | ||||||||||
if ([changes isKindOfClass:RecentsSectionUpdate.class]) | ||||||||||
if ([changes isKindOfClass:NSIndexPath.class]) | ||||||||||
{ | ||||||||||
RecentsSectionUpdate *update = (RecentsSectionUpdate*)changes; | ||||||||||
if (update.isValid && !update.totalCountsChanged) | ||||||||||
NSIndexPath *indexPath = (NSIndexPath *)changes; | ||||||||||
UITableViewCell *cell = [self.recentsTableView cellForRowAtIndexPath:indexPath]; | ||||||||||
if ([cell isKindOfClass:TableViewCellWithCollectionView.class]) | ||||||||||
{ | ||||||||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:update.sectionIndex]; | ||||||||||
UITableViewCell *cell = [self.recentsTableView cellForRowAtIndexPath:indexPath]; | ||||||||||
if ([cell isKindOfClass:TableViewCellWithCollectionView.class]) | ||||||||||
MXLogDebug(@"[RecentsViewController]: Reloading nested collection view cell in section %ld", indexPath.section); | ||||||||||
|
||||||||||
TableViewCellWithCollectionView *collectionViewCell = (TableViewCellWithCollectionView *)cell; | ||||||||||
[collectionViewCell.collectionView reloadData]; | ||||||||||
|
||||||||||
CGRect headerFrame = [self.recentsTableView rectForHeaderInSection:indexPath.section]; | ||||||||||
UIView *headerView = [self.recentsTableView headerViewForSection:indexPath.section]; | ||||||||||
UIView *updatedHeaderView = [self.dataSource viewForHeaderInSection:indexPath.section withFrame:headerFrame inTableView:self.recentsTableView]; | ||||||||||
if ([headerView isKindOfClass:SectionHeaderView.class] | ||||||||||
&& [updatedHeaderView isKindOfClass:SectionHeaderView.class]) | ||||||||||
{ | ||||||||||
TableViewCellWithCollectionView *collectionViewCell = (TableViewCellWithCollectionView *)cell; | ||||||||||
[collectionViewCell.collectionView reloadData]; | ||||||||||
cellReloaded = YES; | ||||||||||
|
||||||||||
CGRect headerFrame = [self.recentsTableView rectForHeaderInSection:update.sectionIndex]; | ||||||||||
UIView *headerView = [self.recentsTableView headerViewForSection:update.sectionIndex]; | ||||||||||
UIView *updatedHeaderView = [self.dataSource viewForHeaderInSection:update.sectionIndex withFrame:headerFrame inTableView:self.recentsTableView]; | ||||||||||
if ([headerView isKindOfClass:SectionHeaderView.class] | ||||||||||
&& [updatedHeaderView isKindOfClass:SectionHeaderView.class]) | ||||||||||
{ | ||||||||||
SectionHeaderView *sectionHeaderView = (SectionHeaderView *)headerView; | ||||||||||
SectionHeaderView *updatedSectionHeaderView = (SectionHeaderView *)updatedHeaderView; | ||||||||||
sectionHeaderView.headerLabel = updatedSectionHeaderView.headerLabel; | ||||||||||
sectionHeaderView.accessoryView = updatedSectionHeaderView.accessoryView; | ||||||||||
sectionHeaderView.rightAccessoryView = updatedSectionHeaderView.rightAccessoryView; | ||||||||||
} | ||||||||||
SectionHeaderView *sectionHeaderView = (SectionHeaderView *)headerView; | ||||||||||
SectionHeaderView *updatedSectionHeaderView = (SectionHeaderView *)updatedHeaderView; | ||||||||||
sectionHeaderView.headerLabel = updatedSectionHeaderView.headerLabel; | ||||||||||
sectionHeaderView.accessoryView = updatedSectionHeaderView.accessoryView; | ||||||||||
sectionHeaderView.rightAccessoryView = updatedSectionHeaderView.rightAccessoryView; | ||||||||||
} | ||||||||||
} else { | ||||||||||
MXLogDebug(@"[RecentsViewController]: Reloading table view section %ld", indexPath.section); | ||||||||||
[self.recentsTableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; | ||||||||||
} | ||||||||||
} else if (!changes) { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
MXLogDebug(@"[RecentsViewController]: Reloading the entire table view"); | ||||||||||
[self refreshRecentsTable]; | ||||||||||
} | ||||||||||
|
||||||||||
if (!cellReloaded) | ||||||||||
{ | ||||||||||
[super dataSource:dataSource didCellChange:changes]; | ||||||||||
} | ||||||||||
else | ||||||||||
{ | ||||||||||
// Since we've enabled room list pagination, `refreshRecentsTable` not called in this case. | ||||||||||
// Refresh tab bar badges separately. | ||||||||||
[[AppDelegate theDelegate].masterTabBarController refreshTabBarBadges]; | ||||||||||
} | ||||||||||
// Since we've enabled room list pagination, `refreshRecentsTable` not called in this case. | ||||||||||
// Refresh tab bar badges separately. | ||||||||||
[[AppDelegate theDelegate].masterTabBarController refreshTabBarBadges]; | ||||||||||
|
||||||||||
[self showEmptyViewIfNeeded]; | ||||||||||
|
||||||||||
if (dataSource.state == MXKDataSourceStateReady) | ||||||||||
{ | ||||||||||
[[NSNotificationCenter defaultCenter] postNotificationName:RecentsViewControllerDataReadyNotification | ||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// | ||
// | ||
// Copyright 2021 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -610,9 +610,10 @@ public class RecentsListService: NSObject, RecentsListServiceProtocol { | |
multicastDelegate.invoke { $0.recentsListServiceDidChangeData?(self, | ||
forSection: section, | ||
totalCountsChanged: totalCountsChanged) } | ||
} else { | ||
multicastDelegate.invoke { $0.recentsListServiceDidChangeData?(self, | ||
totalCountsChanged: totalCountsChanged) } | ||
} | ||
multicastDelegate.invoke { $0.recentsListServiceDidChangeData?(self, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like we have been doing 2 updates when only one was necessary |
||
totalCountsChanged: totalCountsChanged) } | ||
} | ||
|
||
deinit { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Home: Reduce the number of unnecessary home page reloads |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.