fix nested transaction crash on setting notification identifier

This commit is contained in:
Ryan Zhao 2021-08-03 10:42:09 +10:00
parent 885e9296d1
commit 80bf62df90
2 changed files with 2 additions and 3 deletions

View File

@ -221,9 +221,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
AppNotificationUserInfoKey.threadId: threadId
]
let transaction = transaction as! YapDatabaseReadWriteTransaction
let identifier: String = UUID().uuidString
incomingMessage.setNotificationIdentifier(identifier, transaction: transaction)
let identifier: String = incomingMessage.notificationIdentifier ?? UUID().uuidString
DispatchQueue.main.async {
notificationBody = MentionUtilities.highlightMentions(in: notificationBody!, threadID: thread.uniqueId!)

View File

@ -305,6 +305,7 @@ extension MessageReceiver {
// Notify the user if needed
guard (isMainAppAndActive || isBackgroundPoll), let tsIncomingMessage = TSMessage.fetch(uniqueId: tsMessageID, transaction: transaction) as? TSIncomingMessage,
let thread = TSThread.fetch(uniqueId: threadID, transaction: transaction) else { return tsMessageID }
tsIncomingMessage.setNotificationIdentifier(UUID().uuidString, transaction: transaction)
DispatchQueue.main.async {
Storage.read { transaction in
SSKEnvironment.shared.notificationsManager!.notifyUser(for: tsIncomingMessage, in: thread, transaction: transaction)