This commit is contained in:
fmodf 2024-06-21 12:32:16 +02:00
parent 0c8df19d55
commit 47943f15ff
9 changed files with 45 additions and 5 deletions

View file

@ -9,4 +9,5 @@ enum AppAction: Codable {
case xmppAction(_ action: XMPPAction) case xmppAction(_ action: XMPPAction)
case rostersAction(_ action: RostersAction) case rostersAction(_ action: RostersAction)
case chatsAction(_ action: ChatsAction) case chatsAction(_ action: ChatsAction)
case conversationAction(_ action: ConversationAction)
} }

View file

@ -0,0 +1,3 @@
enum ConversationAction: Codable {
case dumb
}

View file

@ -25,10 +25,6 @@ final class ChatsMiddleware {
return Just(.chatsAction(.chatStarted(chat: chat))) return Just(.chatsAction(.chatStarted(chat: chat)))
.eraseToAnyPublisher() .eraseToAnyPublisher()
case .chatsAction(.chatStarted(let chat)):
// TODO: make transition to chat screen
return Empty().eraseToAnyPublisher()
default: default:
return Empty().eraseToAnyPublisher() return Empty().eraseToAnyPublisher()
} }

View file

@ -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()
}
}
}

View file

@ -24,6 +24,9 @@ extension AppState {
case .chatsAction(let action): case .chatsAction(let action):
ChatsState.reducer(state: &state.chatsState, action: action) ChatsState.reducer(state: &state.chatsState, action: action)
case .conversationAction(let action):
ConversationState.reducer(state: &state.conversationsState, action: action)
} }
} }
} }

View file

@ -0,0 +1,11 @@
extension ConversationState {
static func reducer(state: inout ConversationState, action: ConversationAction) {
switch action {
case .dumb:
state.dumb = true
default:
break
}
}
}

View file

@ -17,6 +17,7 @@ struct AppState: Stateable {
var accountsState: AccountsState var accountsState: AccountsState
var rostersState: RostersState var rostersState: RostersState
var chatsState: ChatsState var chatsState: ChatsState
var conversationsState: ConversationState
} }
// MARK: Init // MARK: Init
@ -30,5 +31,6 @@ extension AppState {
accountsState = AccountsState() accountsState = AccountsState()
rostersState = RostersState() rostersState = RostersState()
chatsState = ChatsState() chatsState = ChatsState()
conversationsState = ConversationState()
} }
} }

View file

@ -0,0 +1,11 @@
struct ConversationState: Stateable {
var currentChat: Chat?
var dumb: Bool
}
// MARK: Init
extension ConversationState {
init() {
dumb = false
}
}

View file

@ -12,7 +12,8 @@ let store = AppStore(
AccountsMiddleware.shared.middleware, AccountsMiddleware.shared.middleware,
XMPPMiddleware.shared.middleware, XMPPMiddleware.shared.middleware,
RostersMiddleware.shared.middleware, RostersMiddleware.shared.middleware,
ChatsMiddleware.shared.middleware ChatsMiddleware.shared.middleware,
ConversationMiddleware.shared.middleware
] ]
) )