From bfbbfa85a53880c9b2b8b319d6d9075a61c355fb Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Wed, 11 Mar 2020 15:49:32 +1100 Subject: [PATCH] Avoid nested write transaction --- Signal/src/Loki/Components/ConversationTitleView.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Signal/src/Loki/Components/ConversationTitleView.swift b/Signal/src/Loki/Components/ConversationTitleView.swift index 6f9103012..5aa9cb205 100644 --- a/Signal/src/Loki/Components/ConversationTitleView.swift +++ b/Signal/src/Loki/Components/ConversationTitleView.swift @@ -134,9 +134,12 @@ final class ConversationTitleView : UIView { private func clearStatusIfNeededForMessageWithTimestamp(_ timestamp: NSNumber) { var uncheckedTargetInteraction: TSInteraction? = nil - thread.enumerateInteractions { interaction in - guard interaction.timestamp == timestamp.uint64Value else { return } - uncheckedTargetInteraction = interaction + OWSPrimaryStorage.shared().dbReadConnection.read { transaction in + guard let interactionsByThread = transaction.ext(TSMessageDatabaseViewExtensionName) as? YapDatabaseViewTransaction else { return } + interactionsByThread.enumerateKeysAndObjects(inGroup: self.thread.uniqueId!) { _, _, object, _, _ in + guard let interaction = object as? TSInteraction, interaction.timestamp == timestamp.uint64Value else { return } + uncheckedTargetInteraction = interaction + } } guard let targetInteraction = uncheckedTargetInteraction, targetInteraction.interactionType() == .outgoingMessage else { return } self.currentStatus = nil