19 lines
613 B
Swift
19 lines
613 B
Swift
import Combine
|
|
|
|
final class ConversationMiddleware {
|
|
static let shared = ConversationMiddleware()
|
|
|
|
func middleware(state _: AppState, action: AppAction) -> AnyPublisher<AppAction, Never> {
|
|
switch action {
|
|
case .chatsAction(.chatStarted(let chat)):
|
|
return Just(AppAction.conversationAction(.makeConversationActive(chat: chat))).eraseToAnyPublisher()
|
|
|
|
case .conversationAction(.makeConversationActive):
|
|
return Just(AppAction.changeFlow(.conversation)).eraseToAnyPublisher()
|
|
|
|
default:
|
|
return Empty().eraseToAnyPublisher()
|
|
}
|
|
}
|
|
}
|