From 2bad0c20b637e4a1b542ca844b867e2a49bbe50f Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 12 Nov 2018 15:19:56 -0500 Subject: [PATCH] Only fetch profiles in the main app. --- .../profiles/ProfileFetcherJob.swift | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/SignalMessaging/profiles/ProfileFetcherJob.swift b/SignalMessaging/profiles/ProfileFetcherJob.swift index 1261b3b0e..102fb0190 100644 --- a/SignalMessaging/profiles/ProfileFetcherJob.swift +++ b/SignalMessaging/profiles/ProfileFetcherJob.swift @@ -19,11 +19,19 @@ public class ProfileFetcherJob: NSObject { @objc public class func run(thread: TSThread) { + guard CurrentAppContext().isMainApp else { + return + } + ProfileFetcherJob().run(recipientIds: thread.recipientIdentifiers) } @objc public class func run(recipientId: String, ignoreThrottling: Bool) { + guard CurrentAppContext().isMainApp else { + return + } + ProfileFetcherJob(ignoreThrottling: ignoreThrottling).run(recipientIds: [recipientId]) } @@ -67,6 +75,13 @@ public class ProfileFetcherJob: NSObject { public func run(recipientIds: [String]) { AssertIsOnMainThread() + guard CurrentAppContext().isMainApp else { + // Only refresh profiles in the MainApp to decrease the chance of missed SN notifications + // in the AppExtension for our users who choose not to verify contacts. + owsFailDebug("Should only fetch profiles in the main app") + return + } + backgroundTask = OWSBackgroundTask(label: "\(#function)", completionBlock: { [weak self] status in AssertIsOnMainThread() @@ -79,13 +94,6 @@ public class ProfileFetcherJob: NSObject { Logger.error("background task time ran out before profile fetch completed.") }) - if (!CurrentAppContext().isMainApp) { - // Only refresh profiles in the MainApp to decrease the chance of missed SN notifications - // in the AppExtension for our users who choose not to verify contacts. - owsFailDebug("Should only fetch profiles in the main app") - return - } - DispatchQueue.main.async { for recipientId in recipientIds { self.updateProfile(recipientId: recipientId)