mirror of
https://github.com/localsend/localsend.git
synced 2026-08-07 07:14:52 +00:00
16 lines
600 B
Dart
16 lines
600 B
Dart
import 'package:collection/collection.dart';
|
|
import 'package:localsend_app/model/persistence/favorite_device.dart';
|
|
import 'package:localsend_isolates/model/device.dart';
|
|
|
|
extension FavoriteDevicesExt on Iterable<FavoriteDevice> {
|
|
/// Returns the favorite device with the given [device] or null if not found.
|
|
FavoriteDevice? findDevice(Device device) {
|
|
return firstWhereOrNull((e) => e.fingerprint == device.fingerprint);
|
|
}
|
|
|
|
/// Returns true if the list contains the given [device].
|
|
bool containsDevice(Device device) {
|
|
return any((e) => e.fingerprint == device.fingerprint);
|
|
}
|
|
}
|