From 09a68ebfd8a6728ddcb139869e5170b2cf356a03 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Fri, 14 Aug 2020 13:34:57 +1000 Subject: [PATCH] fix race condition in highlight mentions --- .../src/UserInterface/Notifications/AppNotifications.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Signal/src/UserInterface/Notifications/AppNotifications.swift b/Signal/src/UserInterface/Notifications/AppNotifications.swift index bd74ea59f..29b44b0c0 100644 --- a/Signal/src/UserInterface/Notifications/AppNotifications.swift +++ b/Signal/src/UserInterface/Notifications/AppNotifications.swift @@ -357,7 +357,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol { // it must be escaped. // see https://developer.apple.com/documentation/uikit/uilocalnotification/1616646-alertbody // for more details. - let messageText = MentionUtilities.highlightMentions(in: DisplayableText.filterNotificationText(rawMessageText)!, threadID: thread.uniqueId!) + let messageText = DisplayableText.filterNotificationText(rawMessageText) let senderName = OWSUserProfile.fetch(uniqueId: incomingMessage.authorId, transaction: transaction)?.profileName ?? contactsManager.displayName(forPhoneIdentifier: incomingMessage.authorId) @@ -383,7 +383,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol { } } - let notificationBody: String? + var notificationBody: String? switch previewType { case .noNameNoPreview, .nameNoPreview: notificationBody = NotificationStrings.incomingMessageBody @@ -413,6 +413,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol { ] DispatchQueue.main.async { + notificationBody = MentionUtilities.highlightMentions(in: notificationBody!, threadID: thread.uniqueId!) let sound = self.requestSound(thread: thread) self.adaptee.notify(category: category, title: notificationTitle,