mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-11-18 14:49:15 +00:00
54 lines
1.3 KiB
Dart
54 lines
1.3 KiB
Dart
part of 'devices_bloc.dart';
|
|
|
|
sealed class DevicesState extends Equatable {
|
|
DevicesState({
|
|
required final List<ApiToken> devices,
|
|
}) : _hashCode = Object.hashAll(devices);
|
|
|
|
final int _hashCode;
|
|
|
|
List<ApiToken> get _devices =>
|
|
getIt<ApiConnectionRepository>().apiData.devices.data ?? const [];
|
|
|
|
List<ApiToken> get devices => _devices;
|
|
ApiToken get thisDevice => _devices.firstWhere(
|
|
(final device) => device.isCaller,
|
|
orElse: () => ApiToken(
|
|
name: 'Error fetching device',
|
|
isCaller: true,
|
|
date: DateTime.now(),
|
|
),
|
|
);
|
|
|
|
List<ApiToken> get otherDevices =>
|
|
_devices.where((final device) => !device.isCaller).toList();
|
|
}
|
|
|
|
class DevicesInitial extends DevicesState {
|
|
DevicesInitial() : super(devices: const []);
|
|
|
|
@override
|
|
List<Object> get props => [_hashCode];
|
|
}
|
|
|
|
class DevicesLoaded extends DevicesState {
|
|
DevicesLoaded({required super.devices});
|
|
|
|
@override
|
|
List<Object> get props => [_hashCode];
|
|
}
|
|
|
|
class DevicesError extends DevicesState {
|
|
DevicesError() : super(devices: const []);
|
|
|
|
@override
|
|
List<Object> get props => [_hashCode];
|
|
}
|
|
|
|
class DevicesDeleting extends DevicesState {
|
|
DevicesDeleting({required super.devices});
|
|
|
|
@override
|
|
List<Object> get props => [_hashCode];
|
|
}
|