Skip to content

Commit

Permalink
fix: close #12
Browse files Browse the repository at this point in the history
  • Loading branch information
castdrian committed Dec 16, 2024
1 parent fa29902 commit 4483c6d
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions Tweak.x
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,48 @@

- (void)layoutSubviews {
%orig;
dispatch_async(dispatch_get_main_queue(), ^{
[self removeOffendingCells];

__weak typeof(self) weakSelf = self;

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) return;

@try {
NSArray *visibleCells = [strongSelf visibleCells];
NSMutableArray *indexPathsToRemove = [NSMutableArray array];

for (UICollectionViewCell *cell in visibleCells) {
if (![cell isKindOfClass:NSClassFromString(@"_ASCollectionViewCell")]) {
continue;
}

_ASCollectionViewCell *asCell = (_ASCollectionViewCell *)cell;
if (![asCell respondsToSelector:@selector(node)]) {
continue;
}

id node = [asCell node];
if (![node isKindOfClass:NSClassFromString(@"YTVideoWithContextNode")]) {
continue;
}

if ([strongSelf nodeContainsBlockedChannelName:node] || [strongSelf nodeContainsBlockedVideo:node]) {
NSIndexPath *indexPath = [strongSelf indexPathForCell:cell];
if (indexPath) {
[indexPathsToRemove addObject:indexPath];
}
}
}

if (indexPathsToRemove.count > 0) {
[strongSelf performBatchUpdates:^{
[strongSelf deleteItemsAtIndexPaths:indexPathsToRemove];
} completion:nil];
}
} @catch (NSException *exception) {
NSLog(@"[Gonerino] Exception in removeOffendingCells: %@", exception);
}
});
}

Expand Down

0 comments on commit 4483c6d

Please sign in to comment.