pull/49/head
Niels Andriesse 6 years ago
parent d780c95683
commit 99e8aa5803

@ -1582,12 +1582,11 @@ static NSTimeInterval launchStartedAt;
- (void)createGroupChatPollersIfNeeded - (void)createGroupChatPollersIfNeeded
{ {
// Make sure thread exists // Only create the group chat pollers if their threads aren't deleted
__block TSGroupThread *thread; __block TSGroupThread *thread;
[OWSPrimaryStorage.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [OWSPrimaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
thread = [TSGroupThread threadWithGroupId:[self.lokiPublicChat.id dataUsingEncoding:NSUTF8StringEncoding] transaction:transaction]; thread = [TSGroupThread threadWithGroupId:[self.lokiPublicChat.id dataUsingEncoding:NSUTF8StringEncoding] transaction:transaction];
}]; }];
if (thread != nil && self.lokiPublicChatPoller == nil) { if (thread != nil && self.lokiPublicChatPoller == nil) {
self.lokiPublicChatPoller = [[LKGroupChatPoller alloc] initForGroup:self.lokiPublicChat]; self.lokiPublicChatPoller = [[LKGroupChatPoller alloc] initForGroup:self.lokiPublicChat];
} }
@ -1595,17 +1594,18 @@ static NSTimeInterval launchStartedAt;
- (void)createRSSFeedPollersIfNeeded - (void)createRSSFeedPollersIfNeeded
{ {
// Make sure thread exists // Only create the RSS feed pollers if their threads aren't deleted
__block TSGroupThread *lokiNewsFeedThread; __block TSGroupThread *lokiNewsFeedThread;
[OWSPrimaryStorage.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [OWSPrimaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
lokiNewsFeedThread = [TSGroupThread threadWithGroupId:[self.lokiNewsFeed.id dataUsingEncoding:NSUTF8StringEncoding] transaction:transaction]; lokiNewsFeedThread = [TSGroupThread threadWithGroupId:[self.lokiNewsFeed.id dataUsingEncoding:NSUTF8StringEncoding] transaction:transaction];
}]; }];
if (lokiNewsFeedThread != nil && self.lokiNewsFeedPoller == nil) { if (lokiNewsFeedThread != nil && self.lokiNewsFeedPoller == nil) {
self.lokiNewsFeedPoller = [[LKRSSFeedPoller alloc] initForFeed:self.lokiNewsFeed]; self.lokiNewsFeedPoller = [[LKRSSFeedPoller alloc] initForFeed:self.lokiNewsFeed];
} }
// The user can't delete the Loki Messenger Updates RSS feed
// We don't need to check thread for this as it's never deletable if (self.lokiMessengerUpdatesFeedPoller == nil) {
if (self.lokiMessengerUpdatesFeedPoller == nil) { self.lokiMessengerUpdatesFeedPoller = [[LKRSSFeedPoller alloc] initForFeed:self.lokiMessengerUpdatesFeed]; } self.lokiMessengerUpdatesFeedPoller = [[LKRSSFeedPoller alloc] initForFeed:self.lokiMessengerUpdatesFeed];
}
} }
- (void)startGroupChatPollersIfNeeded - (void)startGroupChatPollersIfNeeded
@ -1623,17 +1623,13 @@ static NSTimeInterval launchStartedAt;
- (void)handleThreadDeleted:(NSNotification *)notification { - (void)handleThreadDeleted:(NSNotification *)notification {
NSDictionary *userInfo = notification.userInfo; NSDictionary *userInfo = notification.userInfo;
NSString *threadId = (NSString *)userInfo[@"threadId"]; NSString *threadID = (NSString *)userInfo[@"threadId"];
if (threadId == nil) { return; } if (threadID == nil) { return; }
if ([threadID isEqualToString:[TSGroupThread threadIdFromGroupId:[self.lokiPublicChat.id dataUsingEncoding:NSUTF8StringEncoding]]] && self.lokiPublicChatPoller != nil) {
// Check if public chat was deleted
if ([threadId isEqualToString:[TSGroupThread threadIdFromGroupId:[self.lokiPublicChat.id dataUsingEncoding:NSUTF8StringEncoding]]] && self.lokiPublicChatPoller != nil) {
[self.lokiPublicChatPoller stop]; [self.lokiPublicChatPoller stop];
self.lokiPublicChatPoller = nil; self.lokiPublicChatPoller = nil;
} }
if ([threadID isEqualToString:[TSGroupThread threadIdFromGroupId:[self.lokiNewsFeed.id dataUsingEncoding:NSUTF8StringEncoding]]] && self.lokiNewsFeedPoller != nil) {
// Check if news feed was deleted
if ([threadId isEqualToString:[TSGroupThread threadIdFromGroupId:[self.lokiNewsFeed.id dataUsingEncoding:NSUTF8StringEncoding]]] && self.lokiNewsFeedPoller != nil) {
[self.lokiNewsFeedPoller stop]; [self.lokiNewsFeedPoller stop];
self.lokiNewsFeedPoller = nil; self.lokiNewsFeedPoller = nil;
} }

Loading…
Cancel
Save