|
|
|
@ -115,9 +115,24 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
OWSSingletonAssert();
|
|
|
|
|
|
|
|
|
|
[self startObserving];
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)startObserving
|
|
|
|
|
{
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
|
selector:@selector(yapDatabaseModified:)
|
|
|
|
|
name:YapDatabaseModifiedNotification
|
|
|
|
|
object:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)yapDatabaseModified:(NSNotification *)notification
|
|
|
|
|
{
|
|
|
|
|
[self updateApplicationBadgeCount];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Debugging
|
|
|
|
|
|
|
|
|
|
- (NSString *)descriptionForEnvelope:(OWSSignalServiceProtosEnvelope *)envelope
|
|
|
|
@ -1068,6 +1083,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
return numberOfItems;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)updateApplicationBadgeCount
|
|
|
|
|
{
|
|
|
|
|
NSUInteger numberOfItems = [self unreadMessagesCount];
|
|
|
|
|
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:numberOfItems];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSUInteger)unreadMessagesInThread:(TSThread *)thread {
|
|
|
|
|
__block NSUInteger numberOfItems;
|
|
|
|
|
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
|
|
|
|