2020-12-03 16:52:53 +00:00
|
|
|
part of 'users_cubit.dart';
|
|
|
|
|
2022-05-17 13:31:34 +00:00
|
|
|
class UsersState extends ServerInstallationDependendState {
|
2022-09-05 10:51:01 +00:00
|
|
|
const UsersState(this.users, this.isLoading);
|
2020-12-03 16:52:53 +00:00
|
|
|
|
|
|
|
final List<User> users;
|
2022-09-05 10:51:01 +00:00
|
|
|
final bool isLoading;
|
2022-09-05 04:01:36 +00:00
|
|
|
|
2022-09-05 04:34:47 +00:00
|
|
|
User get rootUser =>
|
|
|
|
users.firstWhere((final user) => user.type == UserType.root);
|
2022-09-05 04:01:36 +00:00
|
|
|
|
2022-09-05 04:34:47 +00:00
|
|
|
User get primaryUser =>
|
|
|
|
users.firstWhere((final user) => user.type == UserType.primary);
|
2022-09-05 04:01:36 +00:00
|
|
|
|
2022-09-05 04:34:47 +00:00
|
|
|
List<User> get normalUsers =>
|
|
|
|
users.where((final user) => user.type == UserType.normal).toList();
|
2020-12-03 16:52:53 +00:00
|
|
|
|
|
|
|
@override
|
2022-09-05 10:51:01 +00:00
|
|
|
List<Object> get props => [users, isLoading];
|
2022-03-03 17:38:30 +00:00
|
|
|
|
|
|
|
UsersState copyWith({
|
2022-06-05 19:36:32 +00:00
|
|
|
final List<User>? users,
|
2022-09-05 10:51:01 +00:00
|
|
|
final bool? isLoading,
|
2022-06-05 22:40:34 +00:00
|
|
|
}) =>
|
|
|
|
UsersState(
|
|
|
|
users ?? this.users,
|
2022-09-05 10:51:01 +00:00
|
|
|
isLoading ?? this.isLoading,
|
2022-06-05 22:40:34 +00:00
|
|
|
);
|
2021-01-06 17:35:57 +00:00
|
|
|
|
2022-09-05 04:34:47 +00:00
|
|
|
bool isLoginRegistered(final String login) =>
|
|
|
|
users.any((final User user) => user.login == login);
|
2022-05-04 16:58:47 +00:00
|
|
|
|
2021-01-06 17:35:57 +00:00
|
|
|
bool get isEmpty => users.isEmpty;
|
2020-12-03 16:52:53 +00:00
|
|
|
}
|