2024-06-26 06:51:56 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
2024-06-21 10:32:16 +00:00
|
|
|
extension ConversationState {
|
|
|
|
static func reducer(state: inout ConversationState, action: ConversationAction) {
|
|
|
|
switch action {
|
2024-06-26 06:51:56 +00:00
|
|
|
case .makeConversationActive(let chat, let roster):
|
2024-06-21 10:42:50 +00:00
|
|
|
state.currentChat = chat
|
2024-06-26 06:51:56 +00:00
|
|
|
state.currentRoster = roster
|
2024-06-21 10:32:16 +00:00
|
|
|
|
2024-06-26 08:00:59 +00:00
|
|
|
case .messagesUpdated(let messages):
|
|
|
|
state.currentMessages = messages
|
|
|
|
|
2024-06-27 09:54:12 +00:00
|
|
|
case .setReplyText(let text):
|
2024-06-27 11:39:41 +00:00
|
|
|
if text.isEmpty {
|
|
|
|
state.replyText = ""
|
|
|
|
} else {
|
|
|
|
state.replyText = text.makeReply
|
|
|
|
}
|
2024-06-27 09:54:12 +00:00
|
|
|
|
2024-07-11 15:46:57 +00:00
|
|
|
case .attachmentsUpdated(let attachments):
|
|
|
|
state.currentAttachments = attachments
|
|
|
|
|
2024-06-21 10:32:16 +00:00
|
|
|
default:
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|