28 lines
725 B
Swift
28 lines
725 B
Swift
import SwiftUI
|
|
|
|
extension ConversationState {
|
|
static func reducer(state: inout ConversationState, action: ConversationAction) {
|
|
switch action {
|
|
case .makeConversationActive(let chat, let roster):
|
|
state.currentChat = chat
|
|
state.currentRoster = roster
|
|
|
|
case .messagesUpdated(let messages):
|
|
state.currentMessages = messages
|
|
|
|
case .setReplyText(let text):
|
|
if text.isEmpty {
|
|
state.replyText = ""
|
|
} else {
|
|
state.replyText = text.makeReply
|
|
}
|
|
|
|
case .showAttachmentPicker(let flag):
|
|
state.attachmentPickerVisible = flag
|
|
|
|
default:
|
|
break
|
|
}
|
|
}
|
|
}
|