mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-10 08:20:16 +00:00
Match interfacestate update sequence to uikit (#882)
* fix SIMULATE_WEB_RESPONSE not imported #449 * Fix to make rangeMode update in right time * Match interface update closer to UIKit. * allow the correct exiting sequence for thrashing * refactor
This commit is contained in:
parent
cac14e0bce
commit
62b07e100e
@ -2276,15 +2276,23 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
|
|||||||
{
|
{
|
||||||
BOOL visible = (self.window != nil);
|
BOOL visible = (self.window != nil);
|
||||||
ASDisplayNode *node = self.collectionNode;
|
ASDisplayNode *node = self.collectionNode;
|
||||||
|
BOOL rangeControllerNeedsUpdate = ![node supportsRangeManagedInterfaceState];;
|
||||||
|
|
||||||
if (!visible && node.inHierarchy) {
|
if (!visible && node.inHierarchy) {
|
||||||
|
if (rangeControllerNeedsUpdate) {
|
||||||
|
rangeControllerNeedsUpdate = NO;
|
||||||
|
// Exit CellNodes first before Collection to match UIKit behaviors (tear down bottom up).
|
||||||
|
// Although we have not yet cleared the interfaceState's Visible bit (this happens in __exitHierarchy),
|
||||||
|
// the ASRangeController will get the correct value from -interfaceStateForRangeController:.
|
||||||
|
[_rangeController updateRanges];
|
||||||
|
}
|
||||||
[node __exitHierarchy];
|
[node __exitHierarchy];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updating the visible node index paths only for not range managed nodes. Range managed nodes will get their
|
// Updating the visible node index paths only for not range managed nodes. Range managed nodes will get their
|
||||||
// their update in the layout pass
|
// their update in the layout pass
|
||||||
if (![node supportsRangeManagedInterfaceState]) {
|
if (rangeControllerNeedsUpdate) {
|
||||||
[_rangeController setNeedsUpdate];
|
[_rangeController updateRanges];
|
||||||
[_rangeController updateIfNeeded];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// When we aren't visible, we will only fetch up to the visible area. Now that we are visible,
|
// When we aren't visible, we will only fetch up to the visible area. Now that we are visible,
|
||||||
|
|||||||
@ -1907,15 +1907,23 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
{
|
{
|
||||||
BOOL visible = (self.window != nil);
|
BOOL visible = (self.window != nil);
|
||||||
ASDisplayNode *node = self.tableNode;
|
ASDisplayNode *node = self.tableNode;
|
||||||
|
BOOL rangeControllerNeedsUpdate = ![node supportsRangeManagedInterfaceState];;
|
||||||
|
|
||||||
if (!visible && node.inHierarchy) {
|
if (!visible && node.inHierarchy) {
|
||||||
|
if (rangeControllerNeedsUpdate) {
|
||||||
|
rangeControllerNeedsUpdate = NO;
|
||||||
|
// Exit CellNodes first before Table to match UIKit behaviors (tear down bottom up).
|
||||||
|
// Although we have not yet cleared the interfaceState's Visible bit (this happens in __exitHierarchy),
|
||||||
|
// the ASRangeController will get the correct value from -interfaceStateForRangeController:.
|
||||||
|
[_rangeController updateRanges];
|
||||||
|
}
|
||||||
[node __exitHierarchy];
|
[node __exitHierarchy];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updating the visible node index paths only for not range managed nodes. Range managed nodes will get their
|
// Updating the visible node index paths only for not range managed nodes. Range managed nodes will get their
|
||||||
// their update in the layout pass
|
// their update in the layout pass
|
||||||
if (![node supportsRangeManagedInterfaceState]) {
|
if (rangeControllerNeedsUpdate) {
|
||||||
[_rangeController setNeedsUpdate];
|
[_rangeController updateRanges];
|
||||||
[_rangeController updateIfNeeded];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// When we aren't visible, we will only fetch up to the visible area. Now that we are visible,
|
// When we aren't visible, we will only fetch up to the visible area. Now that we are visible,
|
||||||
|
|||||||
@ -64,6 +64,11 @@ AS_SUBCLASSING_RESTRICTED
|
|||||||
*/
|
*/
|
||||||
- (void)updateIfNeeded;
|
- (void)updateIfNeeded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force update the ranges immediately.
|
||||||
|
*/
|
||||||
|
- (void)updateRanges;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the sized node for `indexPath` as a subview of `contentView`.
|
* Add the sized node for `indexPath` as a subview of `contentView`.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -154,12 +154,16 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
|
|||||||
- (void)updateIfNeeded
|
- (void)updateIfNeeded
|
||||||
{
|
{
|
||||||
if (_needsRangeUpdate) {
|
if (_needsRangeUpdate) {
|
||||||
_needsRangeUpdate = NO;
|
[self updateRanges];
|
||||||
|
|
||||||
[self _updateVisibleNodeIndexPaths];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)updateRanges
|
||||||
|
{
|
||||||
|
_needsRangeUpdate = NO;
|
||||||
|
[self _updateVisibleNodeIndexPaths];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode
|
- (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode
|
||||||
{
|
{
|
||||||
_preserveCurrentRangeMode = YES;
|
_preserveCurrentRangeMode = YES;
|
||||||
@ -376,7 +380,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
|
|||||||
[newVisibleNodes addObject:node];
|
[newVisibleNodes addObject:node];
|
||||||
}
|
}
|
||||||
// Skip the many method calls of the recursive operation if the top level cell node already has the right interfaceState.
|
// Skip the many method calls of the recursive operation if the top level cell node already has the right interfaceState.
|
||||||
if (node.interfaceState != interfaceState) {
|
if (node.pendingInterfaceState != interfaceState) {
|
||||||
#if ASRangeControllerLoggingEnabled
|
#if ASRangeControllerLoggingEnabled
|
||||||
[modifiedIndexPaths addObject:indexPath];
|
[modifiedIndexPaths addObject:indexPath];
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user