Skip to content
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

Fix logic cleaning data if delegate / dataSource changes and bring over logic to ASTableView #1200

Merged
merged 3 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
- Yoga integration improvements [Michael Schneider](https://github.com/maicki)[#1187] (https://github.com/TextureGroup/Texture/pull/1187)
- Correct linePositionModifier behavior [Michael Schneider](https://github.com/maicki)[#1192] (https://github.com/TextureGroup/Texture/pull/1192)
- Tweak a11y label aggregation behavior to enable container label overrides [Michael Schneider](https://github.com/maicki)[#1199] (https://github.com/TextureGroup/Texture/pull/1199)
- Fix logic cleaning data if delegate / dataSource changes and bring over logic to ASTableView [Michael Schneider](https://github.com/maicki)[#1200] (https://github.com/TextureGroup/Texture/pull/1200)

## 2.7
- Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877)
Expand Down
14 changes: 10 additions & 4 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,16 @@ - (void)setAsyncDelegate:(id<ASCollectionDelegate>)asyncDelegate
- (void)_asyncDelegateOrDataSourceDidChange
{
ASDisplayNodeAssertMainThread();

if (_asyncDataSource == nil && _asyncDelegate == nil && _isDeallocating && ASActivateExperimentalFeature(ASExperimentalClearDataDuringDeallocation)) {
[_dataController clearData];
}

if (_asyncDataSource == nil && _asyncDelegate == nil) {
if (ASActivateExperimentalFeature(ASExperimentalClearDataDuringDeallocation)) {
if (_isDeallocating) {
[_dataController clearData];
}
} else {
[_dataController clearData];
}
}
}

- (void)setCollectionViewLayout:(nonnull UICollectionViewLayout *)collectionViewLayout
Expand Down
17 changes: 17 additions & 0 deletions Source/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ - (void)setAsyncDataSource:(id<ASTableDataSource>)asyncDataSource

_dataController.validationErrorSource = asyncDataSource;
super.dataSource = (id<UITableViewDataSource>)_proxyDataSource;
[self _asyncDelegateOrDataSourceDidChange];
}

- (id<ASTableDelegate>)asyncDelegate
Expand Down Expand Up @@ -506,6 +507,22 @@ - (void)setAsyncDelegate:(id<ASTableDelegate>)asyncDelegate
}

super.delegate = (id<UITableViewDelegate>)_proxyDelegate;
[self _asyncDelegateOrDataSourceDidChange];
}

- (void)_asyncDelegateOrDataSourceDidChange
{
ASDisplayNodeAssertMainThread();

if (_asyncDataSource == nil && _asyncDelegate == nil) {
if (ASActivateExperimentalFeature(ASExperimentalClearDataDuringDeallocation)) {
if (_isDeallocating) {
[_dataController clearData];
}
} else {
[_dataController clearData];
}
}
}

- (void)proxyTargetHasDeallocated:(ASDelegateProxy *)proxy
Expand Down