mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Fixing a couple speed issues on ios when syncing stories.
This commit is contained in:
parent
b8efcd0713
commit
2f3a8ab983
6 changed files with 27 additions and 18 deletions
|
@ -2310,6 +2310,10 @@
|
|||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
|
||||
(unsigned long)NULL), ^(void) {
|
||||
[self flushOldCachedImages];
|
||||
});
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
|
||||
(unsigned long)NULL), ^(void) {
|
||||
[self.database inTransaction:^(FMDatabase *db, BOOL *rollback) {
|
||||
NSMutableDictionary *hashes = [NSMutableDictionary dictionary];
|
||||
FMResultSet *stories = [db executeQuery:@"SELECT * FROM queued_read_hashes"];
|
||||
|
@ -2395,29 +2399,32 @@
|
|||
|
||||
- (void)flushOldCachedImages {
|
||||
int deleted = 0;
|
||||
int checked = 0;
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
NSString *cacheDirectory = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"story_images"];
|
||||
NSDirectoryEnumerator* en = [fileManager enumeratorAtPath:cacheDirectory];
|
||||
NSDate *d = [[NSDate date] dateByAddingTimeInterval:-14*24*60*60];
|
||||
NSDateFormatter *df = [[NSDateFormatter alloc] init]; // = [NSDateFormatter initWithDateFormat:@"yyyy-MM-dd"];
|
||||
[df setDateFormat:@"EEEE d"];
|
||||
|
||||
NSString *filepath;
|
||||
NSDate *creationDate;
|
||||
NSString* file;
|
||||
while (file = [en nextObject])
|
||||
{
|
||||
NSError *error = nil;
|
||||
NSString *filepath = [NSString stringWithFormat:[cacheDirectory stringByAppendingString:@"/%@"],file];
|
||||
NSDate *creationDate = [[fileManager attributesOfItemAtPath:filepath error:nil] fileCreationDate];
|
||||
NSDate *d = [[NSDate date] dateByAddingTimeInterval:-14*24*60*60];
|
||||
NSDateFormatter *df = [[NSDateFormatter alloc] init]; // = [NSDateFormatter initWithDateFormat:@"yyyy-MM-dd"];
|
||||
[df setDateFormat:@"EEEE d"];
|
||||
filepath = [NSString stringWithFormat:[cacheDirectory stringByAppendingString:@"/%@"],file];
|
||||
creationDate = [[fileManager attributesOfItemAtPath:filepath error:nil] fileCreationDate];
|
||||
checked += 1;
|
||||
|
||||
if ([creationDate compare:d] == NSOrderedAscending) {
|
||||
[[NSFileManager defaultManager]
|
||||
removeItemAtPath:[cacheDirectory stringByAppendingPathComponent:file]
|
||||
error:&error];
|
||||
error:nil];
|
||||
deleted += 1;
|
||||
}
|
||||
}
|
||||
NSLog(@"Deleted %d old cached images", deleted);
|
||||
NSLog(@"Deleted %d/%d old cached images", deleted, checked);
|
||||
}
|
||||
|
||||
- (void)deleteAllCachedImages {
|
||||
|
|
|
@ -752,10 +752,12 @@ static const CGFloat kFolderTitleHeight = 28;
|
|||
|
||||
if (self.inPullToRefresh_) {
|
||||
self.inPullToRefresh_ = NO;
|
||||
[self showSyncingNotifier];
|
||||
[self.appDelegate flushQueuedReadStories:YES withCallback:^{
|
||||
[self.appDelegate startOfflineQueue];
|
||||
}];
|
||||
} else {
|
||||
[self showSyncingNotifier];
|
||||
[self.appDelegate flushQueuedReadStories:YES withCallback:^{
|
||||
[self refreshFeedList];
|
||||
}];
|
||||
|
|
|
@ -88,6 +88,7 @@
|
|||
}
|
||||
NSLog(@"Deleting stories over limit: %d - %d", offlineLimit, offlineLimitTimestamp);
|
||||
[db executeUpdate:[NSString stringWithFormat:@"DELETE FROM unread_hashes WHERE story_timestamp %@ %d", orderComp, offlineLimitTimestamp]];
|
||||
[db executeUpdate:[NSString stringWithFormat:@"DELETE FROM stories WHERE story_timestamp %@ %d", orderComp, offlineLimitTimestamp]];
|
||||
}];
|
||||
|
||||
appDelegate.totalUnfetchedStoryCount = 0;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<key>application-identifier</key>
|
||||
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
|
||||
<key>get-task-allow</key>
|
||||
<false/>
|
||||
<true/>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
|
||||
|
|
|
@ -2652,8 +2652,8 @@
|
|||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Entitlements.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Distribution: NewsBlur, Inc.";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: NewsBlur, Inc.";
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer: Samuel Clay (3PN8E5365D)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Samuel Clay (3PN8E5365D)";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
|
@ -2676,8 +2676,8 @@
|
|||
"-all_load",
|
||||
);
|
||||
PRODUCT_NAME = NewsBlur;
|
||||
PROVISIONING_PROFILE = "EE8BC292-FFF2-41A0-AE29-C4B39D6A2C5A";
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "EE8BC292-FFF2-41A0-AE29-C4B39D6A2C5A";
|
||||
PROVISIONING_PROFILE = "AEE1036A-5198-4D22-9A2F-5D70F071CD89";
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "AEE1036A-5198-4D22-9A2F-5D70F071CD89";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALID_ARCHS = armv7;
|
||||
"WARNING_CFLAGS[arch=*]" = "-Wall";
|
||||
|
@ -2691,8 +2691,8 @@
|
|||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Entitlements.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Distribution: NewsBlur, Inc.";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: NewsBlur, Inc.";
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer: Samuel Clay (3PN8E5365D)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Samuel Clay (3PN8E5365D)";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = NewsBlur_Prefix.pch;
|
||||
|
@ -2712,8 +2712,8 @@
|
|||
"-all_load",
|
||||
);
|
||||
PRODUCT_NAME = NewsBlur;
|
||||
PROVISIONING_PROFILE = "EE8BC292-FFF2-41A0-AE29-C4B39D6A2C5A";
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "EE8BC292-FFF2-41A0-AE29-C4B39D6A2C5A";
|
||||
PROVISIONING_PROFILE = "AEE1036A-5198-4D22-9A2F-5D70F071CD89";
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "AEE1036A-5198-4D22-9A2F-5D70F071CD89";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VALID_ARCHS = armv7;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<li class="NB-splash-link NB-splash-link-about {% if page == "about" %}NB-active{% endif %}"><a href="{% url "about" %}">About</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-faq {% if page == "faq" %}NB-active{% endif %}"><a href="{% url "faq" %}">FAQ</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-api {% if page == "api" %}NB-active{% endif %}"><a href="{% url "api" %}">API</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-press {% if page == "press" %}NB-active{% endif %}"><a href="{% url "press" %}">Press</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-ios {% if page == "ios" %}NB-active{% endif %}"><a href="{% url "ios-static" %}">iOS</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-android {% if page == "android" %}NB-active{% endif %}"><a href="{% url "android-static" %}">Android</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-github"><a href="http://github.com/samuelclay">GitHub</a></li>
|
||||
|
|
Loading…
Add table
Reference in a new issue