mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-11-06 00:43:13 +00:00
35 lines
876 B
Dart
35 lines
876 B
Dart
part of 'users_cubit.dart';
|
|
|
|
class UsersState extends ServerInstallationDependendState {
|
|
const UsersState(this.users, this.isLoading);
|
|
|
|
final List<User> users;
|
|
final bool isLoading;
|
|
|
|
User get rootUser =>
|
|
users.firstWhere((final user) => user.type == UserType.root);
|
|
|
|
User get primaryUser =>
|
|
users.firstWhere((final user) => user.type == UserType.primary);
|
|
|
|
List<User> get normalUsers =>
|
|
users.where((final user) => user.type == UserType.normal).toList();
|
|
|
|
@override
|
|
List<Object> get props => [users, isLoading];
|
|
|
|
UsersState copyWith({
|
|
final List<User>? users,
|
|
final bool? isLoading,
|
|
}) =>
|
|
UsersState(
|
|
users ?? this.users,
|
|
isLoading ?? this.isLoading,
|
|
);
|
|
|
|
bool isLoginRegistered(final String login) =>
|
|
users.any((final User user) => user.login == login);
|
|
|
|
bool get isEmpty => users.isEmpty;
|
|
}
|