mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
feat: manual stack assets (#4198)
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:immich_mobile/shared/models/exif_info.dart';
|
||||
import 'package:immich_mobile/shared/models/store.dart';
|
||||
import 'package:immich_mobile/shared/models/user.dart';
|
||||
import 'package:immich_mobile/shared/providers/db.provider.dart';
|
||||
import 'package:immich_mobile/shared/providers/user.provider.dart';
|
||||
import 'package:immich_mobile/shared/services/asset.service.dart';
|
||||
import 'package:immich_mobile/modules/home/ui/asset_grid/asset_grid_data_structure.dart';
|
||||
import 'package:immich_mobile/modules/settings/providers/app_settings.provider.dart';
|
||||
@@ -217,6 +218,7 @@ final assetsProvider =
|
||||
.filter()
|
||||
.isArchivedEqualTo(false)
|
||||
.isTrashedEqualTo(false)
|
||||
.stackParentIdIsNull()
|
||||
.sortByFileCreatedAtDesc();
|
||||
final settings = ref.watch(appSettingsServiceProvider);
|
||||
final groupBy =
|
||||
@@ -227,10 +229,12 @@ final assetsProvider =
|
||||
}
|
||||
});
|
||||
|
||||
final remoteAssetsProvider =
|
||||
StreamProvider.family<RenderList, int?>((ref, userId) async* {
|
||||
if (userId == null) return;
|
||||
final query = ref
|
||||
QueryBuilder<Asset, Asset, QAfterSortBy>? getRemoteAssetQuery(WidgetRef ref) {
|
||||
final userId = ref.watch(currentUserProvider)?.isarId;
|
||||
if (userId == null) {
|
||||
return null;
|
||||
}
|
||||
return ref
|
||||
.watch(dbProvider)
|
||||
.assets
|
||||
.where()
|
||||
@@ -238,12 +242,34 @@ final remoteAssetsProvider =
|
||||
.filter()
|
||||
.ownerIdEqualTo(userId)
|
||||
.isTrashedEqualTo(false)
|
||||
.stackParentIdIsNull()
|
||||
.sortByFileCreatedAtDesc();
|
||||
final settings = ref.watch(appSettingsServiceProvider);
|
||||
final groupBy =
|
||||
GroupAssetsBy.values[settings.getSetting(AppSettingsEnum.groupAssetsBy)];
|
||||
yield await RenderList.fromQuery(query, groupBy);
|
||||
await for (final _ in query.watchLazy()) {
|
||||
yield await RenderList.fromQuery(query, groupBy);
|
||||
}
|
||||
|
||||
QueryBuilder<Asset, Asset, QAfterSortBy>? getAssetStackSelectionQuery(
|
||||
WidgetRef ref,
|
||||
Asset parentAsset,
|
||||
) {
|
||||
final userId = ref.watch(currentUserProvider)?.isarId;
|
||||
if (userId == null || !parentAsset.isRemote) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
return ref
|
||||
.watch(dbProvider)
|
||||
.assets
|
||||
.where()
|
||||
.remoteIdIsNotNull()
|
||||
.filter()
|
||||
.isArchivedEqualTo(false)
|
||||
.ownerIdEqualTo(userId)
|
||||
.not()
|
||||
.remoteIdEqualTo(parentAsset.remoteId)
|
||||
// Show existing stack children in selection page
|
||||
.group(
|
||||
(q) => q
|
||||
.stackParentIdIsNull()
|
||||
.or()
|
||||
.stackParentIdEqualTo(parentAsset.remoteId),
|
||||
)
|
||||
.sortByFileCreatedAtDesc();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user