Created
March 9, 2018 03:53
-
-
Save rosem/ffbc651a1ba57392e47bb450831a931a to your computer and use it in GitHub Desktop.
Crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - Auth | |
- (void)updateNotifications:(NSNumber*)favorites messages:(NSNumber*)messages created:(NSNumber*)created { | |
if (!favorites && !messages && !created) { return; } | |
if (![NSThread isMainThread]) { | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
[self updateNotifications:favorites messages:messages created:created]; | |
}); | |
return; | |
} | |
NSUInteger appCount = 0; | |
if (favorites) { | |
appCount += [favorites intValue]; | |
} | |
if (messages) { | |
appCount += [messages intValue]; | |
} | |
if (created) { | |
appCount += [created intValue]; | |
} | |
[UIApplication sharedApplication].applicationIconBadgeNumber = appCount; | |
if (favorites) { | |
if (!( self.currentUser.notifications_count && [favorites compare:self.currentUser.notifications_count] == NSOrderedSame )){ | |
self.currentUser.notifications_count = favorites; | |
if ( [favorites intValue] == 0 ){ | |
self.followingNavController.tabBarItem.badgeValue = nil; | |
} | |
else{ | |
self.followingNavController.tabBarItem.badgeValue = [favorites stringValue]; | |
} | |
} | |
} | |
if ( messages ){ | |
if (!( self.currentUser.unread_chats && [messages compare:self.currentUser.unread_chats] == NSOrderedSame )){ | |
self.currentUser.unread_chats = messages; | |
if ( [messages intValue] == 0 ) { | |
self.privateChatViewController.tabBarItem.badgeValue = nil; | |
} | |
else { | |
self.privateChatViewController.tabBarItem.badgeValue = [messages stringValue]; | |
} | |
} | |
} | |
if ( created ){ | |
if (!( self.currentUser.unread_events && [created compare:self.currentUser.unread_events] == NSOrderedSame )){ | |
self.currentUser.unread_events = created; | |
if ( [created intValue] == 0 ){ | |
self.notificationsNavController.tabBarItem.badgeValue = nil; | |
} | |
else{ | |
self.notificationsNavController.tabBarItem.badgeValue = [created stringValue]; | |
// TODO: Found out why this was needed... current causes crashes on notifications | |
// 3/8/201 | |
/* | |
if ( self.tabBarController.selectedViewController == self.notificationsNavController && self.notificationsNavController.visibleViewController == self.notificationsNavController.topViewController ){ | |
[self.notificationsNavController.topViewController performSelector:@selector(refreshFromServer)]; | |
} | |
*/ | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment