Fix crash when opening wallpaper/chat color view

_I recommend reviewing this with whitespace changes disabled._

Previously, Settings → Appearance → Chat Color & Wallpaper → Chat Color
would cause a crash. This was because we had a re-entrant database
transaction.

This fixes that by removing the re-entrant transaction—a fairly simple
fix.

There was also a function here that was immediately called and not used
elsewhere, so I removed the function and inlined its contents. Not
strictly related to the crash. I believe it was originally added in
0574d23b6f.
This commit is contained in:
Evan Hahn 2022-06-15 12:14:56 -05:00 committed by Evan Hahn
parent 8c0cc50a0c
commit 779142ea0c

View File

@ -129,18 +129,16 @@ class MockConversationView: UIView {
chatColor: chatColor
)
for item in model.items {
func buildInteraction() -> TSInteraction {
switch item {
case .date:
return DateHeaderInteraction(thread: self.thread,
timestamp: NSDate.ows_millisecondTimeStamp())
case .outgoing(let text):
return databaseStorage.read { MockOutgoingMessage(messageBody: text, thread: self.thread, transaction: $0) }
case .incoming(let text):
return MockIncomingMessage(messageBody: text, thread: self.thread)
}
let interaction: TSInteraction
switch item {
case .date:
interaction = DateHeaderInteraction(thread: self.thread, timestamp: NSDate.ows_millisecondTimeStamp())
case .outgoing(let text):
interaction = MockOutgoingMessage(messageBody: text, thread: self.thread, transaction: transaction)
case .incoming(let text):
interaction = MockIncomingMessage(messageBody: text, thread: self.thread)
}
let interaction = buildInteraction()
guard let renderItem = CVLoader.buildStandaloneRenderItem(
interaction: interaction,
thread: self.thread,