From e0ef9aac66deddd4935b9febab5866c747355726 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Fri, 21 Feb 2020 10:40:44 +0700 Subject: [PATCH] Clean --- Signal/src/AppDelegate.h | 2 + Signal/src/AppDelegate.m | 49 ++++++++++++------- Signal/src/Loki/View Controllers/HomeVC.swift | 2 +- .../HomeView/HomeViewController.m | 1 + 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/Signal/src/AppDelegate.h b/Signal/src/AppDelegate.h index 3cf39a281..e36cdadca 100644 --- a/Signal/src/AppDelegate.h +++ b/Signal/src/AppDelegate.h @@ -11,6 +11,8 @@ extern NSString *const AppDelegateStoryboardMain; - (void)startLongPollerIfNeeded; - (void)stopLongPollerIfNeeded; - (void)setUpDefaultPublicChatsIfNeeded; +- (void)startOpenGroupPollersIfNeeded; +- (void)stopOpenGroupPollersIfNeeded; - (void)createRSSFeedsIfNeeded; - (void)startRSSFeedPollersIfNeeded; diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 61f8f0c5c..25a8de660 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -177,7 +177,9 @@ static NSTimeInterval launchStartedAt; [DDLog flushLog]; + // Loki: Stop pollers [self stopLongPollerIfNeeded]; + [self stopOpenGroupPollersIfNeeded]; } - (void)applicationWillEnterForeground:(UIApplication *)application @@ -195,8 +197,10 @@ static NSTimeInterval launchStartedAt; OWSLogInfo(@"applicationWillTerminate."); [DDLog flushLog]; - + + // Loki: Stop pollers [self stopLongPollerIfNeeded]; + [self stopOpenGroupPollersIfNeeded]; if (self.lokiP2PServer) { [self.lokiP2PServer stop]; } } @@ -772,8 +776,9 @@ static NSTimeInterval launchStartedAt; // Loki: Tell our friends that we are online [LKP2PAPI broadcastOnlineStatus]; - // Loki: Start long polling + // Loki: Start pollers [self startLongPollerIfNeeded]; + [self startOpenGroupPollersIfNeeded]; // Loki: Get device links [[LKFileServerAPI getDeviceLinksAssociatedWith:userHexEncodedPublicKey] retainUntilComplete]; @@ -1464,8 +1469,9 @@ static NSTimeInterval launchStartedAt; // Loki: Start friend request expiration job [self.lokiFriendRequestExpirationJob startIfNecessary]; - // Loki: Start long polling + // Loki: Start pollers [self startLongPollerIfNeeded]; + [self startOpenGroupPollersIfNeeded]; // Loki: Get device links [[LKFileServerAPI getDeviceLinksAssociatedWith:self.tsAccountManager.localNumber] retainUntilComplete]; // TODO: Is this even needed? @@ -1599,26 +1605,11 @@ static NSTimeInterval launchStartedAt; { [self setUpLongPollerIfNeeded]; [self.lokiLongPoller startIfNeeded]; - // FIXME: Let's not mix long polling and public chat polling. Better to separate them out into their own functions. - [LKPublicChatManager.shared startPollersIfNeeded]; - [SSKEnvironment.shared.attachmentDownloads continueDownloadIfPossible]; } - (void)stopLongPollerIfNeeded { [self.lokiLongPoller stopIfNeeded]; - // FIXME: Let's not mix long polling and public chat polling. Better to separate them out into their own functions. - [LKPublicChatManager.shared stopPollers]; -} - -- (LKRSSFeed *)lokiNewsFeed -{ - return [[LKRSSFeed alloc] initWithId:@"loki.network.feed" server:@"https://loki.network/feed/" displayName:@"Loki News" isDeletable:true]; -} - -- (LKRSSFeed *)lokiMessengerUpdatesFeed -{ - return [[LKRSSFeed alloc] initWithId:@"loki.network.messenger-updates.feed" server:@"https://loki.network/category/messenger-updates/feed/" displayName:@"Session Updates" isDeletable:false]; } - (void)setUpDefaultPublicChatsIfNeeded @@ -1637,6 +1628,27 @@ static NSTimeInterval launchStartedAt; } } +- (void)startOpenGroupPollersIfNeeded +{ + [LKPublicChatManager.shared startPollersIfNeeded]; + [SSKEnvironment.shared.attachmentDownloads continueDownloadIfPossible]; +} + +- (void)stopOpenGroupPollersIfNeeded +{ + [LKPublicChatManager.shared stopPollers]; +} + +- (LKRSSFeed *)lokiNewsFeed +{ + return [[LKRSSFeed alloc] initWithId:@"loki.network.feed" server:@"https://loki.network/feed/" displayName:@"Loki News" isDeletable:true]; +} + +- (LKRSSFeed *)lokiMessengerUpdatesFeed +{ + return [[LKRSSFeed alloc] initWithId:@"loki.network.messenger-updates.feed" server:@"https://loki.network/category/messenger-updates/feed/" displayName:@"Session Updates" isDeletable:false]; +} + - (void)createRSSFeedsIfNeeded { NSArray *feeds = @[ /*self.lokiNewsFeed,*/ self.lokiMessengerUpdatesFeed ]; @@ -1695,6 +1707,7 @@ static NSTimeInterval launchStartedAt; [SSKEnvironment.shared.identityManager clearIdentityKey]; [LKAPI clearRandomSnodePool]; [self stopLongPollerIfNeeded]; + [self stopOpenGroupPollersIfNeeded]; [self.lokiNewsFeedPoller stop]; [self.lokiMessengerUpdatesFeedPoller stop]; [LKPublicChatManager.shared stopPollers]; diff --git a/Signal/src/Loki/View Controllers/HomeVC.swift b/Signal/src/Loki/View Controllers/HomeVC.swift index 3e8efcab1..554f65498 100644 --- a/Signal/src/Loki/View Controllers/HomeVC.swift +++ b/Signal/src/Loki/View Controllers/HomeVC.swift @@ -135,8 +135,8 @@ final class HomeVC : UIViewController, UITableViewDataSource, UITableViewDelegat if OWSIdentityManager.shared().identityKeyPair() != nil { let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.setUpDefaultPublicChatsIfNeeded() + appDelegate.startOpenGroupPollersIfNeeded() appDelegate.createRSSFeedsIfNeeded() - LokiPublicChatManager.shared.startPollersIfNeeded() appDelegate.startRSSFeedPollersIfNeeded() } // Do initial update diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index 14404235d..6e65a8e0f 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -682,6 +682,7 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { [LKAPI clearRandomSnodePool]; AppDelegate *appDelegate = (AppDelegate *)UIApplication.sharedApplication.delegate; [appDelegate stopLongPollerIfNeeded]; + [appDelegate stopOpenGroupPollersIfNeeded]; [SSKEnvironment.shared.tsAccountManager resetForReregistration]; UIViewController *rootViewController = [[OnboardingController new] initialViewController]; OWSNavigationController *navigationController = [[OWSNavigationController alloc] initWithRootViewController:rootViewController];