Reduce animations in transcript
This commit is contained in:
@@ -54,7 +54,9 @@ struct MessageEntryView: View
|
|||||||
}
|
}
|
||||||
|
|
||||||
.onChange(of: selectedConversation) { oldValue, newValue in
|
.onChange(of: selectedConversation) { oldValue, newValue in
|
||||||
viewModel.draftText = ""
|
if oldValue?.id != newValue?.id {
|
||||||
|
viewModel.draftText = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ struct TranscriptView: View
|
|||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
.scaleEffect(CGSize(width: 1.0, height: -1.0))
|
.scaleEffect(CGSize(width: 1.0, height: -1.0))
|
||||||
.id(model.displayedConversation)
|
.id(model.displayedConversation?.id)
|
||||||
.task { await watchForMessageListChanges() }
|
.task { await watchForMessageListChanges() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,9 @@ struct TranscriptView: View
|
|||||||
case .attachmentDownloaded(let attachmentId):
|
case .attachmentDownloaded(let attachmentId):
|
||||||
model.attachmentDownloaded(id: attachmentId)
|
model.attachmentDownloaded(id: attachmentId)
|
||||||
case .messagesUpdated(let conversationId):
|
case .messagesUpdated(let conversationId):
|
||||||
if let displayedConversation = model.displayedConversation, conversationId == displayedConversation.id {
|
if let displayedConversation = model.displayedConversation,
|
||||||
|
conversationId == displayedConversation.id
|
||||||
|
{
|
||||||
model.setNeedsReload(animated: true)
|
model.setNeedsReload(animated: true)
|
||||||
}
|
}
|
||||||
case .updateStreamReconnected:
|
case .updateStreamReconnected:
|
||||||
@@ -159,8 +161,14 @@ struct TranscriptView: View
|
|||||||
let clientMessages = try await client.getMessages(conversationId: displayedConversation.id)
|
let clientMessages = try await client.getMessages(conversationId: displayedConversation.id)
|
||||||
.map { Display.Message(from: $0) }
|
.map { Display.Message(from: $0) }
|
||||||
|
|
||||||
|
let newIds = Set(clientMessages.map(\.id))
|
||||||
|
.subtracting(self.messages.map(\.id))
|
||||||
|
|
||||||
|
// Only animate for incoming messages.
|
||||||
|
let shouldAnimate = (newIds.count == 1)
|
||||||
|
|
||||||
self.messages = clientMessages
|
self.messages = clientMessages
|
||||||
self.rebuildDisplayItems(animated: animated)
|
self.rebuildDisplayItems(animated: animated && shouldAnimate)
|
||||||
} catch {
|
} catch {
|
||||||
print("Message fetch error: \(error)")
|
print("Message fetch error: \(error)")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user