private fun savedLoginsStateReducer( state: LoginsListState, action: LoginsAction, ): LoginsListState { return when (action) { is LoginsAction.LoginsListUpToDate -> { state.copy(isLoading = false) } is LoginsAction.UpdateLoginsList -> { state.copy( isLoading = false, loginList = action.list, filteredItems = state.sortingStrategy(action.list), ) } is LoginsAction.FilterLogins -> { filterItems( action.newText, state.sortingStrategy, state, ) } is LoginsAction.UpdateCurrentLogin -> { state.copy( currentItem = action.item, ) } is LoginsAction.SortLogins -> { filterItems( state.searchedForText, action.sortingStrategy, state, ) } is LoginsAction.LoginSelected -> { state.copy( isLoading = true, ) } is LoginsAction.DuplicateLogin -> { state.copy( duplicateLogin = action.dupe, ) } } }
Handles changes in the saved logins list, including updates and filtering.