mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Add setNeedsDataFetch method to queue off screen fetchData calls
This commit is contained in:
@@ -442,7 +442,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*
|
||||
* @see displaySuspended and setNeedsDisplay
|
||||
*/
|
||||
|
||||
- (void)recursivelyClearContents;
|
||||
|
||||
/**
|
||||
@@ -465,6 +464,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (void)recursivelyFetchData;
|
||||
|
||||
/**
|
||||
* @abstract Marks the node as needing to call fetchData
|
||||
* @discussion If the node is outside of the preload range, it is queued to call fetchData the next time it enters the range.
|
||||
* Otherwise, fetchData is called immediately if the node is currently within the preload range.
|
||||
*/
|
||||
- (void)setNeedsDataFetch;
|
||||
|
||||
/**
|
||||
* @abstract Toggle displaying a placeholder over the node that covers content until the node and all subnodes are
|
||||
* displayed.
|
||||
|
||||
@@ -1727,6 +1727,15 @@ static BOOL ShouldUseNewRenderingRange = YES;
|
||||
// subclass override
|
||||
}
|
||||
|
||||
- (void)setNeedsDataFetch
|
||||
{
|
||||
if (ASInterfaceStateIncludesFetchData(_interfaceState)) {
|
||||
[self fetchData];
|
||||
} else {
|
||||
_needsDataFetch = YES;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Replace this with ASDisplayNodePerformBlockOnEveryNode or enterInterfaceState:
|
||||
- (void)recursivelyFetchData
|
||||
{
|
||||
@@ -1793,9 +1802,10 @@ static BOOL ShouldUseNewRenderingRange = YES;
|
||||
BOOL nowFetchData = ASInterfaceStateIncludesFetchData(newState);
|
||||
BOOL wasFetchData = ASInterfaceStateIncludesFetchData(oldState);
|
||||
|
||||
if (nowFetchData != wasFetchData) {
|
||||
if (nowFetchData) {
|
||||
if (nowFetchData != wasFetchData || _needsDataFetch) {
|
||||
if (nowFetchData || _needsDataFetch) {
|
||||
[self fetchData];
|
||||
_needsDataFetch = NO;
|
||||
} else {
|
||||
if ([self supportsRangeManagedInterfaceState]) {
|
||||
[self clearFetchedData];
|
||||
|
||||
@@ -29,6 +29,33 @@ inline BOOL ASInterfaceStateIncludesFetchData(ASInterfaceState interfaceState)
|
||||
return ((interfaceState & ASInterfaceStateFetchData) == ASInterfaceStateFetchData);
|
||||
}
|
||||
|
||||
inline BOOL ASInterfaceStateIncludesMeasureLayout(ASInterfaceState interfaceState)
|
||||
{
|
||||
return ((interfaceState & ASInterfaceStateMeasureLayout) == ASInterfaceStateMeasureLayout);
|
||||
}
|
||||
|
||||
inline NSString * _Nonnull NSStringFromASInterfaceState(ASInterfaceState interfaceState)
|
||||
{
|
||||
NSMutableString *result = [NSMutableString stringWithString:@"{ "];
|
||||
if (interfaceState == ASInterfaceStateNone) {
|
||||
[result appendString:@"No state"];
|
||||
}
|
||||
if (ASInterfaceStateIncludesMeasureLayout(interfaceState)) {
|
||||
[result appendString:@"MeasureLayout"];
|
||||
}
|
||||
if (ASInterfaceStateIncludesFetchData(interfaceState)) {
|
||||
[result appendString:@" - FetchData"];
|
||||
}
|
||||
if (ASInterfaceStateIncludesDisplay(interfaceState)) {
|
||||
[result appendString:@" - Display"];
|
||||
}
|
||||
if (ASInterfaceStateIncludesVisible(interfaceState)) {
|
||||
[result appendString:@" - Visible"];
|
||||
}
|
||||
[result appendString:@" }"];
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
ASDISPLAYNODE_EXTERN_C_BEGIN
|
||||
|
||||
@@ -101,6 +101,8 @@ typedef NS_OPTIONS(NSUInteger, ASDisplayNodeMethodOverrides)
|
||||
|
||||
ASDisplayNodeExtraIvars _extra;
|
||||
|
||||
BOOL _needsDataFetch;
|
||||
|
||||
#if TIME_DISPLAYNODE_OPS
|
||||
@public
|
||||
NSTimeInterval _debugTimeToCreateView;
|
||||
|
||||
Reference in New Issue
Block a user