Skip to content

Commit 964bb07

Browse files
Improved quoting image animation
1 parent 2820eb4 commit 964bb07

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

Sources/StreamChatSwiftUI/ChatChannel/ChatChannelViewModel.swift

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ open class ChatChannelViewModel: ObservableObject, MessagesDataSource {
3939

4040
private var loadingPreviousMessages: Bool = false
4141
private var lastMessageRead: String?
42+
private var disableDateIndicator = false
4243

4344
public var channelController: ChatChannelController
4445
public var messageController: ChatMessageController?
@@ -74,7 +75,14 @@ open class ChatChannelViewModel: ObservableObject, MessagesDataSource {
7475
}
7576
}
7677

77-
@Published public var quotedMessage: ChatMessage?
78+
@Published public var quotedMessage: ChatMessage? {
79+
didSet {
80+
if oldValue != nil && quotedMessage == nil {
81+
disableDateIndicator = true
82+
}
83+
}
84+
}
85+
7886
@Published public var editedMessage: ChatMessage?
7987
@Published public var channelHeaderType: ChannelHeaderType = .regular
8088

@@ -232,6 +240,11 @@ open class ChatChannelViewModel: ObservableObject, MessagesDataSource {
232240
}
233241

234242
private func save(lastDate: Date) {
243+
if disableDateIndicator {
244+
enableDateIndicator()
245+
return
246+
}
247+
235248
currentDate = lastDate
236249
timer?.invalidate()
237250
timer = Timer.scheduledTimer(
@@ -339,6 +352,12 @@ open class ChatChannelViewModel: ObservableObject, MessagesDataSource {
339352
return false
340353
}
341354

355+
private func enableDateIndicator() {
356+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
357+
self?.disableDateIndicator = false
358+
}
359+
}
360+
342361
deinit {
343362
messageCachingUtils.clearCache()
344363
}
@@ -377,7 +396,11 @@ extension ChatMessage: Identifiable {
377396
states += fileAttachments.compactMap { $0.uploadingState?.state }
378397

379398
if states.isEmpty {
380-
return "empty"
399+
if localState == .sendingFailed {
400+
return "failed"
401+
} else {
402+
return "empty"
403+
}
381404
}
382405

383406
let strings = states.map { "\($0)" }

Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ public struct MessageComposerView<Factory: ViewFactory>: View, KeyboardReadable
5050
factory.makeQuotedMessageHeaderView(
5151
quotedMessage: $quotedMessage
5252
)
53+
.transition(.identity)
5354
} else if editedMessage != nil {
5455
factory.makeEditedMessageHeaderView(
5556
editedMessage: $editedMessage
5657
)
58+
.transition(.identity)
5759
}
5860

5961
HStack(alignment: .bottom) {

0 commit comments

Comments
 (0)