23 lines
726 B
Swift
23 lines
726 B
Swift
extension AccountsState {
|
|
static func reducer(state: inout AccountsState, action: AccountsAction) {
|
|
switch action {
|
|
case .accountsListUpdated(let accounts):
|
|
state.accounts = accounts
|
|
|
|
case .goTo(let navigation):
|
|
state.navigation = navigation
|
|
|
|
case .tryAddAccountWithCredentials(let login, let password):
|
|
let account = Account(bareJid: login, pass: password, isActive: true, isTemp: true)
|
|
state.accounts.append(account)
|
|
|
|
case .addAccountError(let jid, let reason):
|
|
state.accounts = state.accounts.filter { $0.bareJid != jid }
|
|
state.addAccountError = reason
|
|
|
|
default:
|
|
break
|
|
}
|
|
}
|
|
}
|