wip
This commit is contained in:
parent
0c8df19d55
commit
47943f15ff
|
@ -9,4 +9,5 @@ enum AppAction: Codable {
|
|||
case xmppAction(_ action: XMPPAction)
|
||||
case rostersAction(_ action: RostersAction)
|
||||
case chatsAction(_ action: ChatsAction)
|
||||
case conversationAction(_ action: ConversationAction)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
enum ConversationAction: Codable {
|
||||
case dumb
|
||||
}
|
|
@ -25,10 +25,6 @@ final class ChatsMiddleware {
|
|||
return Just(.chatsAction(.chatStarted(chat: chat)))
|
||||
.eraseToAnyPublisher()
|
||||
|
||||
case .chatsAction(.chatStarted(let chat)):
|
||||
// TODO: make transition to chat screen
|
||||
return Empty().eraseToAnyPublisher()
|
||||
|
||||
default:
|
||||
return Empty().eraseToAnyPublisher()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import Combine
|
||||
|
||||
final class ConversationMiddleware {
|
||||
static let shared = ConversationMiddleware()
|
||||
|
||||
func middleware(state _: AppState, action: AppAction) -> AnyPublisher<AppAction, Never> {
|
||||
switch action {
|
||||
default:
|
||||
return Empty().eraseToAnyPublisher()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,6 +24,9 @@ extension AppState {
|
|||
|
||||
case .chatsAction(let action):
|
||||
ChatsState.reducer(state: &state.chatsState, action: action)
|
||||
|
||||
case .conversationAction(let action):
|
||||
ConversationState.reducer(state: &state.conversationsState, action: action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
extension ConversationState {
|
||||
static func reducer(state: inout ConversationState, action: ConversationAction) {
|
||||
switch action {
|
||||
case .dumb:
|
||||
state.dumb = true
|
||||
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ struct AppState: Stateable {
|
|||
var accountsState: AccountsState
|
||||
var rostersState: RostersState
|
||||
var chatsState: ChatsState
|
||||
var conversationsState: ConversationState
|
||||
}
|
||||
|
||||
// MARK: Init
|
||||
|
@ -30,5 +31,6 @@ extension AppState {
|
|||
accountsState = AccountsState()
|
||||
rostersState = RostersState()
|
||||
chatsState = ChatsState()
|
||||
conversationsState = ConversationState()
|
||||
}
|
||||
}
|
||||
|
|
11
ConversationsClassic/AppCore/State/ConversationState.swift
Normal file
11
ConversationsClassic/AppCore/State/ConversationState.swift
Normal file
|
@ -0,0 +1,11 @@
|
|||
struct ConversationState: Stateable {
|
||||
var currentChat: Chat?
|
||||
var dumb: Bool
|
||||
}
|
||||
|
||||
// MARK: Init
|
||||
extension ConversationState {
|
||||
init() {
|
||||
dumb = false
|
||||
}
|
||||
}
|
|
@ -12,7 +12,8 @@ let store = AppStore(
|
|||
AccountsMiddleware.shared.middleware,
|
||||
XMPPMiddleware.shared.middleware,
|
||||
RostersMiddleware.shared.middleware,
|
||||
ChatsMiddleware.shared.middleware
|
||||
ChatsMiddleware.shared.middleware,
|
||||
ConversationMiddleware.shared.middleware
|
||||
]
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue