#1304 (not restoring state)

- Fixed issue with background operations that could result in the app getting killed.
This commit is contained in:
David Sinclair 2020-05-26 15:35:53 -07:00
parent 95f3f3b3a6
commit bfe81aff54
2 changed files with 7 additions and 9 deletions

View file

@ -55,7 +55,6 @@
@property (readwrite) BOOL isHidingStory;
@property (readwrite) BOOL feedDetailIsVisible;
@property (readwrite) BOOL keyboardIsShown;
@property (nonatomic) UIBackgroundTaskIdentifier reorientBackgroundTask;
@end
@ -230,11 +229,9 @@
if (self.feedDetailIsVisible) {
// Defer this in the background, to avoid misaligning the detail views
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
self.reorientBackgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:self.reorientBackgroundTask];
self.reorientBackgroundTask = UIBackgroundTaskInvalid;
}];
[self performSelector:@selector(delayedReorientPages) withObject:nil afterDelay:0.5];
NSString *networkOperationIdentifier = [appDelegate beginNetworkOperation];
[self performSelector:@selector(delayedReorientPages:) withObject:networkOperationIdentifier afterDelay:0.5];
} else {
[self.storyPageControl reorientPages];
}
@ -268,10 +265,9 @@
}
}
- (void)delayedReorientPages {
- (void)delayedReorientPages:(NSString *)identifier {
[self.storyPageControl reorientPages];
[[UIApplication sharedApplication] endBackgroundTask:self.reorientBackgroundTask];
self.reorientBackgroundTask = UIBackgroundTaskInvalid;
[appDelegate endNetworkOperation:identifier];
}
- (void)checkSize:(CGSize)size {

View file

@ -342,6 +342,8 @@ SFSafariViewControllerDelegate> {
- (void)recalculateIntelligenceScores:(id)feedId;
- (void)cancelRequests;
- (NSString *)beginNetworkOperation;
- (void)endNetworkOperation:(NSString *)networkOperationIdentifier;
- (void)GET:(NSString *)urlString parameters:(id)parameters
success:(void (^)(NSURLSessionDataTask *, id))success