Skip to content

Commit

Permalink
fix(ios): nested list may not get reload
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg authored and hippy-actions[bot] committed Dec 22, 2023
1 parent ee057dc commit 80d68c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,9 @@ - (void)setScrollEnabled:(BOOL)value {

#pragma mark - Data Load

- (void)hippyBridgeDidFinishTransaction {
HippyShadowListView *listNode = self.hippyShadowView;
if (listNode && listNode.itemChangeContext.hasChanges) {
[self reloadData];
[listNode.itemChangeContext clear];
}
}

// BaseListview's super is WaterfallView
// here we use super's hippyBridgeDidFinishTransaction imp to trigger reload,
// and override reloadData to handle special logic
- (void)reloadData {
NSArray<HippyShadowView *> *datasource = [self.hippyShadowView.subcomponents copy];
self->_dataSource = [[NativeRenderBaseListViewDataSource alloc] initWithDataSource:datasource
Expand Down Expand Up @@ -274,16 +269,17 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
[shadowView isKindOfClass:NativeRenderObjectWaterfallItem.class] &&
!((NativeRenderObjectWaterfallItem *)shadowView).layoutDirty) {
cellView = cachedVisibleCellView;
HippyLogTrace(@"🟢 use cached visible cellView at %@ for %@", indexPath, shadowView.hippyTag);
} else {
cellView = [self.renderImpl createViewForShadowListItem:shadowView];
[_cachedVisibleCellViews setObject:cellView forKey:shadowView.hippyTag];
HippyLogTrace(@"🟡 create cellView at %@ for %@", indexPath, shadowView.hippyTag);
}

HippyAssert([cellView conformsToProtocol:@protocol(ViewAppearStateProtocol)],
@"subviews of NativeRenderBaseListViewCell must conform to protocol ViewAppearStateProtocol");
cell.cellView = cellView;
cellView.parent = self;

return cell;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ - (BOOL)isManualScrolling {

- (void)hippyBridgeDidFinishTransaction {
HippyShadowListView *listNode = self.hippyShadowView;
if (listNode.itemChangeContext.hasChanges) {
if (!_dataSource || (listNode && listNode.itemChangeContext.hasChanges)) {
HippyLogTrace(@"🔥 %@ Reload %@", self.hippyTag, [[listNode itemChangeContext] description]);
[self reloadData];
[listNode.itemChangeContext clear];
}
Expand Down

0 comments on commit 80d68c9

Please sign in to comment.