#1797 (cold boot should preserve feeds and icons)

- The “when opening app” preference now only shows the folder if there are some unread stories (when offline or after loading).
- Now displays the number of cached favicons next to the username, as a temporary hack to help diagnose this issue.
This commit is contained in:
David Sinclair 2023-06-28 15:51:15 -07:00
parent 9a7dfac4e1
commit 26734f98a5

View file

@ -898,7 +898,11 @@ static NSArray<NSString *> *NewsBlurTopSectionNames;
[self cacheFeedRowLocations];
}
if (!self.isOffline) {
if (appDelegate.pendingFolder != nil) {
if ([appDelegate splitUnreadCountForFolder:appDelegate.pendingFolder].nt > 0) {
[self loadNotificationStory];
}
} else {
[self loadNotificationStory];
}
@ -2852,8 +2856,23 @@ heightForHeaderInSection:(NSInteger)section {
[userInfoView addSubview:userAvatarButton];
#warning tracing issue #1797
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *PINDiskCachePrefix = @"com.pinterest.PINDiskCache";
NSString *cacheName = @"NBFavicons";
NSString *pathComponent = [[NSString alloc] initWithFormat:@"%@.%@", PINDiskCachePrefix, cacheName];
NSURL *cacheURL = [NSURL fileURLWithPathComponents:@[ rootPath, pathComponent ]];
NSError *error = nil;
NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:cacheURL
includingPropertiesForKeys:nil
options:NSDirectoryEnumerationSkipsHiddenFiles
error:&error];
NSLog(@"🌄 %@ disk cache contains %@ files; error: %@", cacheName, @(files.count), error); // log
userLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, yOffset, userInfoView.frame.size.width, 16)];
userLabel.text = appDelegate.activeUsername;
userLabel.text = [NSString stringWithFormat:@"%@ — 🌄 %@ icons", appDelegate.activeUsername, @(files.count)]; // appDelegate.activeUsername;
userLabel.font = userLabelFont;
userLabel.textColor = UIColorFromRGB(0x404040);
userLabel.backgroundColor = [UIColor clearColor];