Only fetch profiles in the main app.

pull/1/head
Matthew Chen 7 years ago
parent 7f89c90f16
commit 2bad0c20b6

@ -19,11 +19,19 @@ public class ProfileFetcherJob: NSObject {
@objc @objc
public class func run(thread: TSThread) { public class func run(thread: TSThread) {
guard CurrentAppContext().isMainApp else {
return
}
ProfileFetcherJob().run(recipientIds: thread.recipientIdentifiers) ProfileFetcherJob().run(recipientIds: thread.recipientIdentifiers)
} }
@objc @objc
public class func run(recipientId: String, ignoreThrottling: Bool) { public class func run(recipientId: String, ignoreThrottling: Bool) {
guard CurrentAppContext().isMainApp else {
return
}
ProfileFetcherJob(ignoreThrottling: ignoreThrottling).run(recipientIds: [recipientId]) ProfileFetcherJob(ignoreThrottling: ignoreThrottling).run(recipientIds: [recipientId])
} }
@ -67,6 +75,13 @@ public class ProfileFetcherJob: NSObject {
public func run(recipientIds: [String]) { public func run(recipientIds: [String]) {
AssertIsOnMainThread() 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 backgroundTask = OWSBackgroundTask(label: "\(#function)", completionBlock: { [weak self] status in
AssertIsOnMainThread() AssertIsOnMainThread()
@ -79,13 +94,6 @@ public class ProfileFetcherJob: NSObject {
Logger.error("background task time ran out before profile fetch completed.") 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 { DispatchQueue.main.async {
for recipientId in recipientIds { for recipientId in recipientIds {
self.updateProfile(recipientId: recipientId) self.updateProfile(recipientId: recipientId)

Loading…
Cancel
Save