2022-05-26 01:02:06 +00:00
|
|
|
part of 'devices_cubit.dart';
|
|
|
|
|
|
|
|
class ApiDevicesState extends ServerInstallationDependendState {
|
|
|
|
const ApiDevicesState(this._devices, this.status);
|
|
|
|
|
|
|
|
const ApiDevicesState.initial() : this(const [], LoadingStatus.uninitialized);
|
|
|
|
final List<ApiToken> _devices;
|
|
|
|
final LoadingStatus status;
|
|
|
|
|
|
|
|
List<ApiToken> get devices => _devices;
|
2022-06-05 22:40:34 +00:00
|
|
|
ApiToken get thisDevice => _devices.firstWhere(
|
|
|
|
(final device) => device.isCaller,
|
|
|
|
orElse: () => ApiToken(
|
|
|
|
name: 'Error fetching device',
|
|
|
|
isCaller: true,
|
|
|
|
date: DateTime.now(),
|
|
|
|
),
|
|
|
|
);
|
2022-05-26 01:02:06 +00:00
|
|
|
|
|
|
|
List<ApiToken> get otherDevices =>
|
2022-06-05 19:36:32 +00:00
|
|
|
_devices.where((final device) => !device.isCaller).toList();
|
2022-05-26 01:02:06 +00:00
|
|
|
|
|
|
|
ApiDevicesState copyWith({
|
2022-06-05 19:36:32 +00:00
|
|
|
final List<ApiToken>? devices,
|
|
|
|
final LoadingStatus? status,
|
2022-06-05 22:40:34 +00:00
|
|
|
}) =>
|
|
|
|
ApiDevicesState(
|
|
|
|
devices ?? _devices,
|
|
|
|
status ?? this.status,
|
|
|
|
);
|
2022-05-26 01:02:06 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
List<Object?> get props => [_devices];
|
|
|
|
}
|