From 9b4329e2fec9c1da9c57839b0eda628ba7c5e9a6 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Mon, 3 Aug 2020 10:50:15 +1000 Subject: [PATCH] Clean --- .../NotificationServiceExtension.swift | 1 - Signal/src/AppDelegate.m | 4 ++-- Signal/src/Loki/View Controllers/HomeVC.swift | 9 ++++----- .../ConversationView/ConversationViewController.m | 3 +-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/LokiPushNotificationService/NotificationServiceExtension.swift b/LokiPushNotificationService/NotificationServiceExtension.swift index fe2e628dd..7d7e87c7a 100644 --- a/LokiPushNotificationService/NotificationServiceExtension.swift +++ b/LokiPushNotificationService/NotificationServiceExtension.swift @@ -20,7 +20,6 @@ final class NotificationServiceExtension : UNNotificationServiceExtension { if let sharedUserDefaults = UserDefaults(suiteName: "group.com.loki-project.loki-messenger") { isMainAppActive = sharedUserDefaults.bool(forKey: "isMainAppActive") } - print("[Ryan debug] isMainAppActive \(isMainAppActive)") // If the main app is running, skip the whole process guard !isMainAppActive else { return self.completeWithFailure(content: notificationContent!) } diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 7641580f4..1e7718390 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -308,7 +308,7 @@ static NSTimeInterval launchStartedAt; } NSUserDefaults *sharedUserDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.loki-project.loki-messenger"]; - [sharedUserDefaults setBool:true forKey:@"isMainAppActive"]; + [sharedUserDefaults setBool:YES forKey:@"isMainAppActive"]; [sharedUserDefaults synchronize]; [self ensureRootViewController]; @@ -339,7 +339,7 @@ static NSTimeInterval launchStartedAt; [self clearAllNotificationsAndRestoreBadgeCount]; NSUserDefaults *sharedUserDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.loki-project.loki-messenger"]; - [sharedUserDefaults setBool:false forKey:@"isMainAppActive"]; + [sharedUserDefaults setBool:NO forKey:@"isMainAppActive"]; [sharedUserDefaults synchronize]; [DDLog flushLog]; diff --git a/Signal/src/Loki/View Controllers/HomeVC.swift b/Signal/src/Loki/View Controllers/HomeVC.swift index 93df55a85..5738e3a78 100644 --- a/Signal/src/Loki/View Controllers/HomeVC.swift +++ b/Signal/src/Loki/View Controllers/HomeVC.swift @@ -4,8 +4,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol private var isObservingDatabase = true private var isViewVisible = false { didSet { updateIsObservingDatabase() } } private var tableViewTopConstraint: NSLayoutConstraint! - - private var hasDatabaseModifiedNotificationWhenInvisible = false + private var wasDatabaseModifiedExternally = false private var threads: YapDatabaseViewMappings = { let result = YapDatabaseViewMappings(groups: [ TSInboxGroup ], view: TSThreadDatabaseViewExtensionName) @@ -235,7 +234,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol let ext = uiDatabaseConnection.ext(TSThreadDatabaseViewExtensionName) as! YapDatabaseViewConnection let hasChanges = ext.hasChanges(forGroup: TSInboxGroup, in: notifications) guard isObservingDatabase else { - hasDatabaseModifiedNotificationWhenInvisible = hasChanges + wasDatabaseModifiedExternally = hasChanges return } guard hasChanges else { @@ -280,9 +279,9 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol @objc private func handleApplicationDidBecomeActiveNotification(_ notification: Notification) { updateIsObservingDatabase() - if (hasDatabaseModifiedNotificationWhenInvisible) { + if wasDatabaseModifiedExternally { reload() - hasDatabaseModifiedNotificationWhenInvisible = false + wasDatabaseModifiedExternally = false } } diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 33f3667f4..fa8cbd875 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -842,8 +842,7 @@ typedef enum : NSUInteger { - (void)applicationDidBecomeActive:(NSNotification *)notification { [self startReadTimer]; - [self.conversationViewModel viewDidLoad]; - [self.conversationViewModel loadAnotherPageOfMessages]; + [self resetContentAndLayout]; } - (void)dismissPresentedViewControllerIfNecessary