mirror of
https://github.com/immich-app/immich.git
synced 2024-12-21 01:39:59 +02:00
bcc2c34eef
* feat(mobile): partner sharing * getAllAssets for other users * i18n * fix tests * try to fix web tests * shared with/by confusion * error logging * guard against outdated server version
51 lines
1.7 KiB
Dart
51 lines
1.7 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/modules/album/providers/suggested_shared_users.provider.dart';
|
|
import 'package:immich_mobile/shared/models/user.dart';
|
|
import 'package:immich_mobile/shared/providers/db.provider.dart';
|
|
import 'package:isar/isar.dart';
|
|
|
|
class PartnerSharedWithNotifier extends StateNotifier<List<User>> {
|
|
PartnerSharedWithNotifier(Isar db) : super([]) {
|
|
final query = db.users.filter().isPartnerSharedWithEqualTo(true);
|
|
query.findAll().then((partners) => state = partners);
|
|
query.watch().listen((partners) => state = partners);
|
|
}
|
|
}
|
|
|
|
final partnerSharedWithProvider =
|
|
StateNotifierProvider<PartnerSharedWithNotifier, List<User>>((ref) {
|
|
return PartnerSharedWithNotifier(ref.watch(dbProvider));
|
|
});
|
|
|
|
class PartnerSharedByNotifier extends StateNotifier<List<User>> {
|
|
PartnerSharedByNotifier(Isar db) : super([]) {
|
|
final query = db.users.filter().isPartnerSharedByEqualTo(true);
|
|
query.findAll().then((partners) => state = partners);
|
|
streamSub = query.watch().listen((partners) => state = partners);
|
|
}
|
|
|
|
late final StreamSubscription<List<User>> streamSub;
|
|
|
|
@override
|
|
void dispose() {
|
|
streamSub.cancel();
|
|
super.dispose();
|
|
}
|
|
}
|
|
|
|
final partnerSharedByProvider =
|
|
StateNotifierProvider<PartnerSharedByNotifier, List<User>>((ref) {
|
|
return PartnerSharedByNotifier(ref.watch(dbProvider));
|
|
});
|
|
|
|
final partnerAvailableProvider =
|
|
FutureProvider.autoDispose<List<User>>((ref) async {
|
|
final otherUsers = await ref.watch(otherUsersProvider.future);
|
|
final currentPartners = ref.watch(partnerSharedByProvider);
|
|
final available = Set<User>.of(otherUsers);
|
|
available.removeAll(currentPartners);
|
|
return available.toList();
|
|
});
|