Skip to content

Commit f9f298f

Browse files
authored
Add forceCheckForBatchFetching (#2140)
* Add forceCheckForBatchFetching ## Summary We want the ability to control when and how batch fetching occurs, so add a method to force a batch fetching check even if we're scrolling. * Update simulator and SDK versions * Try another simulator * Update simulator device * idk, pick something random * Take it back * Just update to CI's latest and see what breaks * Fix snapshot tests and other things related to 2x vs 3x * Fix debug string * wut I don't know why CI is suddenly choking on the examples. Monkey with the minimum sdk
1 parent 34de002 commit f9f298f

612 files changed

Lines changed: 41 additions & 20 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-master-only.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
cocoapods-lint:
1010
env:
11-
DEVELOPER_DIR: /Applications/Xcode_26.0.1.app/Contents/Developer
11+
DEVELOPER_DIR: /Applications/Xcode_26.5.0.app/Contents/Developer
1212
name: Verify that podspec lints
1313
runs-on: macos-latest
1414
steps:

.github/workflows/ci-pull-requests-only.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
buildsh:
1010
env:
11-
DEVELOPER_DIR: /Applications/Xcode_26.0.1.app/Contents/Developer
11+
DEVELOPER_DIR: /Applications/Xcode_26.5.0.app/Contents/Developer
1212
strategy:
1313
matrix:
1414
mode: [cocoapods-lint-default-subspecs, cocoapods-lint-other-subspecs]

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [push, pull_request]
55
jobs:
66
buildsh:
77
env:
8-
DEVELOPER_DIR: /Applications/Xcode_26.0.1.app/Contents/Developer
8+
DEVELOPER_DIR: /Applications/Xcode_26.5.0.app/Contents/Developer
99
strategy:
1010
matrix:
1111
mode: [tests, framework, life-without-cocoapods, carthage, examples-pt1, examples-pt2, examples-pt3, examples-pt4]

Source/ASCollectionNode.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,11 @@ NS_ASSUME_NONNULL_BEGIN
547547
*/
548548
- (nullable id<ASSectionContext>)contextForSection:(NSInteger)section AS_WARN_UNUSED_RESULT;
549549

550+
/**
551+
Force a check for batch fetching. Ignores if the user is scrolling.
552+
*/
553+
- (void)forceCheckForBatchFetching;
554+
550555
@end
551556

552557
@interface ASCollectionNode (Deprecated)

Source/ASCollectionNode.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,11 @@ - (nullable UICollectionViewCell *)cellForItemAtIndexPath:(NSIndexPath *)indexPa
967967
return [self.dataController.pendingMap contextForSection:section];
968968
}
969969

970+
- (void)forceCheckForBatchFetching
971+
{
972+
[self.view forceCheckForBatchFetching];
973+
}
974+
970975
#pragma mark - Editing
971976

972977
- (void)registerSupplementaryNodeOfKind:(NSString *)elementKind

Source/ASCollectionView.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ NS_ASSUME_NONNULL_BEGIN
8181
*/
8282
- (nullable id<ASSectionContext>)contextForSection:(NSInteger)section AS_WARN_UNUSED_RESULT NS_SWIFT_UI_ACTOR;
8383

84+
/**
85+
Force a check for batch fetching. Ignores if the user is scrolling.
86+
*/
87+
- (void)forceCheckForBatchFetching;
88+
8489
@end
8590

8691
@interface ASCollectionView (Deprecated)

Source/ASCollectionView.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,11 @@ - (void)_scheduleCheckForBatchFetchingForNumberOfChanges:(NSUInteger)changes
18611861
});
18621862
}
18631863

1864+
- (void)forceCheckForBatchFetching
1865+
{
1866+
[self _beginBatchFetchingIfNeededWithContentOffset:self.contentOffset velocity:CGPointZero];
1867+
}
1868+
18641869
- (void)_checkForBatchFetching
18651870
{
18661871
// Dragging will be handled in scrollViewWillEndDragging:withVelocity:targetContentOffset:

Source/TextExperiment/Component/ASTextLayout.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,17 +1597,17 @@ - (ASTextPosition *)closestPositionToPoint:(CGPoint)point {
15971597

15981598
[self _insideComposedCharacterSequences:line position:position block: ^(CGFloat left, CGFloat right, NSUInteger prev, NSUInteger next) {
15991599
if (isVertical) {
1600-
position = fabs(left - point.y) < fabs(right - point.y) < (right ? prev : next);
1600+
position = fabs(left - point.y) < fabs(right - point.y) ? prev : next;
16011601
} else {
1602-
position = fabs(left - point.x) < fabs(right - point.x) < (right ? prev : next);
1602+
position = fabs(left - point.x) < fabs(right - point.x) ? prev : next;
16031603
}
16041604
}];
16051605

16061606
[self _insideEmoji:line position:position block: ^(CGFloat left, CGFloat right, NSUInteger prev, NSUInteger next) {
16071607
if (isVertical) {
1608-
position = fabs(left - point.y) < fabs(right - point.y) < (right ? prev : next);
1608+
position = fabs(left - point.y) < fabs(right - point.y) ? prev : next;
16091609
} else {
1610-
position = fabs(left - point.x) < fabs(right - point.x) < (right ? prev : next);
1610+
position = fabs(left - point.x) < fabs(right - point.x) ? prev : next;
16111611
}
16121612
}];
16131613

Tests/ASDisplayNodeTests.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ - (void)checkValuesMatchDefaults:(ASDisplayNode *)node isLayerBacked:(BOOL)isLay
472472
XCTAssertTrue(CGRectEqualToRect(CGRectZero, node.frame), @"default frame broken %@", hasLoadedView);
473473
XCTAssertTrue(CGPointEqualToPoint(CGPointZero, node.position), @"default position broken %@", hasLoadedView);
474474
XCTAssertEqual((CGFloat)0.0, node.zPosition, @"default zPosition broken %@", hasLoadedView);
475-
XCTAssertEqual(node.isNodeLoaded && isLayerBacked ? 2.0f : 1.0f, node.contentsScale, @"default contentsScale broken %@", hasLoadedView);
475+
XCTAssertEqual(node.isNodeLoaded && isLayerBacked ? 3.0f : 1.0f, node.contentsScale, @"default contentsScale broken %@", hasLoadedView);
476476
XCTAssertEqual([UIScreen mainScreen].scale, node.contentsScaleForDisplay, @"default contentsScaleForDisplay broken %@", hasLoadedView);
477477
XCTAssertTrue(CATransform3DEqualToTransform(CATransform3DIdentity, node.transform), @"default transform broken %@", hasLoadedView);
478478
XCTAssertTrue(CATransform3DEqualToTransform(CATransform3DIdentity, node.subnodeTransform), @"default subnodeTransform broken %@", hasLoadedView);
@@ -2111,8 +2111,8 @@ - (void)testDebugDescription
21112111
NSString *viewDescription = [parent.view valueForKey:@"recursiveDescription"];
21122112

21132113
// Make sure string contains a, b, and c's pointer string
2114-
XCTAssertTrue(stringContainsPointer(viewDescription, a), @"Layer backed node not present");
2115-
XCTAssertTrue(stringContainsPointer(viewDescription, b), @"Layer-backed node not present");
2114+
XCTAssertTrue(stringContainsPointer(viewDescription, a.layer), @"Layer backed node not present");
2115+
XCTAssertTrue(stringContainsPointer(viewDescription, b.layer), @"Layer-backed node not present");
21162116
XCTAssertTrue(stringContainsPointer(viewDescription, c), @"View-backed node not present");
21172117

21182118
// Make sure layer names have display node in description

Tests/ASStackLayoutSpecSnapshotTests.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,8 +1216,8 @@ - (void)testBaselineAlignmentWithStretchedItem
12161216
- (void)testFlexWrapWithItemSpacings
12171217
{
12181218
ASStackLayoutSpecStyle style = {
1219-
.spacing = 50,
12201219
.direction = ASStackLayoutDirectionHorizontal,
1220+
.spacing = 50,
12211221
.flexWrap = ASStackLayoutFlexWrapWrap,
12221222
.alignContent = ASStackLayoutAlignContentStart,
12231223
.lineSpacing = 5,
@@ -1246,8 +1246,8 @@ - (void)testFlexWrapWithItemSpacings
12461246
- (void)testFlexWrapWithItemSpacingsBeingResetOnNewLines
12471247
{
12481248
ASStackLayoutSpecStyle style = {
1249-
.spacing = 5,
12501249
.direction = ASStackLayoutDirectionHorizontal,
1250+
.spacing = 5,
12511251
.flexWrap = ASStackLayoutFlexWrapWrap,
12521252
.alignContent = ASStackLayoutAlignContentStart,
12531253
.lineSpacing = 5,
@@ -1327,9 +1327,9 @@ - (void)testAlignContentStretchAndOtherAlignments
13271327
{
13281328
ASStackLayoutSpecStyle style = {
13291329
.direction = ASStackLayoutDirectionHorizontal,
1330+
.alignItems = ASStackLayoutAlignItemsStart,
13301331
.flexWrap = ASStackLayoutFlexWrapWrap,
13311332
.alignContent = ASStackLayoutAlignContentStretch,
1332-
.alignItems = ASStackLayoutAlignItemsStart,
13331333
};
13341334

13351335
CGSize subnodeSize = {50, 50};

0 commit comments

Comments
 (0)