2024-06-21 10:32:16 +00:00
|
|
|
import Combine
|
|
|
|
|
|
|
|
final class ConversationMiddleware {
|
|
|
|
static let shared = ConversationMiddleware()
|
|
|
|
|
|
|
|
func middleware(state _: AppState, action: AppAction) -> AnyPublisher<AppAction, Never> {
|
|
|
|
switch action {
|
2024-06-21 10:42:50 +00:00
|
|
|
case .chatsAction(.chatStarted(let chat)):
|
|
|
|
return Just(AppAction.conversationAction(.makeConversationActive(chat: chat))).eraseToAnyPublisher()
|
|
|
|
|
|
|
|
case .conversationAction(.makeConversationActive):
|
|
|
|
return Just(AppAction.changeFlow(.conversation)).eraseToAnyPublisher()
|
|
|
|
|
2024-06-21 10:32:16 +00:00
|
|
|
default:
|
|
|
|
return Empty().eraseToAnyPublisher()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|