another.im-ios/ConversationsClassic/AppCore/Reducers/ConversationReducer.swift

28 lines
725 B
Swift
Raw Normal View History

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-02 08:32:14 +00:00
case .showAttachmentPicker(let flag):
state.attachmentPickerVisible = flag
2024-06-21 10:32:16 +00:00
default:
break
}
}
}