mirror of
https://github.com/immich-app/immich.git
synced 2025-09-29 15:31:13 -04:00
fix: properly display "add photos"
This commit is contained in:
parent
d61569faf6
commit
34eca2bd17
@ -120,6 +120,10 @@ class RemoteAlbumService {
|
||||
return _repository.getSharedUsers(albumId);
|
||||
}
|
||||
|
||||
Future<AlbumUserRole?> getUserRole(String albumId, String userId) {
|
||||
return _repository.getUserRole(albumId, userId);
|
||||
}
|
||||
|
||||
Future<List<RemoteAsset>> getAssets(String albumId) {
|
||||
return _repository.getAssets(albumId);
|
||||
}
|
||||
|
@ -221,6 +221,15 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
|
||||
.get();
|
||||
}
|
||||
|
||||
Future<AlbumUserRole?> getUserRole(String albumId, String userId) async {
|
||||
final query = _db.remoteAlbumUserEntity.select()
|
||||
..where((row) => row.albumId.equals(albumId) & row.userId.equals(userId))
|
||||
..limit(1);
|
||||
|
||||
final result = await query.getSingleOrNull();
|
||||
return result?.role;
|
||||
}
|
||||
|
||||
Future<List<RemoteAsset>> getAssets(String albumId) {
|
||||
final query = _db.remoteAlbumAssetEntity.select().join([
|
||||
innerJoin(_db.remoteAssetEntity, _db.remoteAssetEntity.id.equalsExp(_db.remoteAlbumAssetEntity.assetId)),
|
||||
|
@ -169,9 +169,10 @@ class _RemoteAlbumPageState extends ConsumerState<RemoteAlbumPage> {
|
||||
context.pushRoute(const DriftActivitiesRoute());
|
||||
}
|
||||
|
||||
void showOptionSheet(BuildContext context) {
|
||||
Future<void> showOptionSheet(BuildContext context) async {
|
||||
final user = ref.watch(currentUserProvider);
|
||||
final isOwner = user != null ? user.id == _album.ownerId : false;
|
||||
final canEdit = await ref.read(remoteAlbumUserRoleProvider((_album.id, user!.id)).future) == AlbumUserRole.editor;
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
@ -193,10 +194,12 @@ class _RemoteAlbumPageState extends ConsumerState<RemoteAlbumPage> {
|
||||
context.pop();
|
||||
}
|
||||
: null,
|
||||
onAddPhotos: () async {
|
||||
await addAssets(context);
|
||||
context.pop();
|
||||
},
|
||||
onAddPhotos: isOwner || canEdit
|
||||
? () async {
|
||||
await addAssets(context);
|
||||
context.pop();
|
||||
}
|
||||
: null,
|
||||
onToggleAlbumOrder: () async {
|
||||
await toggleAlbumOrder();
|
||||
context.pop();
|
||||
|
@ -178,3 +178,13 @@ final remoteAlbumSharedUsersProvider = FutureProvider.autoDispose.family<List<Us
|
||||
final service = ref.watch(remoteAlbumServiceProvider);
|
||||
return service.getSharedUsers(albumId);
|
||||
});
|
||||
|
||||
final remoteAlbumUserRoleProvider = FutureProvider.autoDispose.family<AlbumUserRole?, (String, String)>((
|
||||
ref,
|
||||
data,
|
||||
) async {
|
||||
final link = ref.keepAlive();
|
||||
ref.onDispose(() => link.close());
|
||||
final service = ref.watch(remoteAlbumServiceProvider);
|
||||
return service.getUserRole(data.$1, data.$2);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user