26 lines
841 B
Swift
26 lines
841 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
|
|
|
|
case .clientServerFeaturesUpdated(let jid, let features):
|
|
state.discoFeatures[jid] = features
|
|
|
|
default:
|
|
break
|
|
}
|
|
}
|
|
}
|