Skip to content

Commit d3b7fe0

Browse files
committed
feat: get owner name
1 parent 4b45ac8 commit d3b7fe0

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

mobile/lib/domain/models/album/album.model.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Album {
2222
final bool isActivityEnabled;
2323
final AlbumAssetOrder order;
2424
final int assetCount;
25+
final String ownerName;
2526

2627
const Album({
2728
required this.id,
@@ -34,6 +35,7 @@ class Album {
3435
required this.isActivityEnabled,
3536
required this.order,
3637
required this.assetCount,
38+
this.ownerName = "",
3739
});
3840

3941
@override
@@ -48,7 +50,8 @@ class Album {
4850
isActivityEnabled: $isActivityEnabled,
4951
order: $order,
5052
thumbnailAssetId: ${thumbnailAssetId ?? "<NA>"}
51-
assetCount: $assetCount
53+
assetCount: $assetCount
54+
ownerName: $ownerName
5255
}''';
5356
}
5457

@@ -65,7 +68,8 @@ class Album {
6568
thumbnailAssetId == other.thumbnailAssetId &&
6669
isActivityEnabled == other.isActivityEnabled &&
6770
order == other.order &&
68-
assetCount == other.assetCount;
71+
assetCount == other.assetCount &&
72+
ownerName == other.ownerName;
6973
}
7074

7175
@override
@@ -79,6 +83,7 @@ class Album {
7983
thumbnailAssetId.hashCode ^
8084
isActivityEnabled.hashCode ^
8185
order.hashCode ^
82-
assetCount.hashCode;
86+
assetCount.hashCode ^
87+
ownerName.hashCode;
8388
}
8489
}

mobile/lib/infrastructure/repositories/remote_album.repository.dart

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
1818
_db.remoteAlbumAssetEntity.albumId.equalsExp(_db.remoteAlbumEntity.id),
1919
useColumns: false,
2020
),
21+
leftOuterJoin(
22+
_db.userEntity,
23+
_db.userEntity.id.equalsExp(_db.remoteAlbumEntity.ownerId),
24+
),
2125
]);
2226
query
2327
..addColumns([assetCount])
@@ -28,7 +32,7 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
2832
for (final sort in sortBy) {
2933
orderings.add(
3034
switch (sort) {
31-
SortRemoteAlbumsBy.id => OrderingTerm.asc(_db.remoteAssetEntity.id),
35+
SortRemoteAlbumsBy.id => OrderingTerm.asc(_db.remoteAlbumEntity.id),
3236
},
3337
);
3438
}
@@ -37,16 +41,17 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
3741

3842
return query
3943
.map(
40-
(row) => row
41-
.readTable(_db.remoteAlbumEntity)
42-
.toDto(assetCount: row.read(assetCount) ?? 0),
44+
(row) => row.readTable(_db.remoteAlbumEntity).toDto(
45+
assetCount: row.read(assetCount) ?? 0,
46+
ownerName: row.readTableOrNull(_db.userEntity)?.name,
47+
),
4348
)
4449
.get();
4550
}
4651
}
4752

4853
extension on RemoteAlbumEntityData {
49-
Album toDto({int assetCount = 0}) {
54+
Album toDto({int assetCount = 0, String? ownerName}) {
5055
return Album(
5156
id: id,
5257
name: name,
@@ -58,6 +63,7 @@ extension on RemoteAlbumEntityData {
5863
isActivityEnabled: isActivityEnabled,
5964
order: order,
6065
assetCount: assetCount,
66+
ownerName: ownerName ?? '',
6167
);
6268
}
6369
}

mobile/lib/presentation/pages/drift_album.page.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:auto_route/auto_route.dart';
55
import 'package:easy_localization/easy_localization.dart';
66
import 'package:flutter/material.dart';
77
import 'package:hooks_riverpod/hooks_riverpod.dart';
8+
import 'package:immich_mobile/domain/models/album/album.model.dart';
89
import 'package:immich_mobile/extensions/build_context_extensions.dart';
910
import 'package:immich_mobile/extensions/theme_extensions.dart';
1011
import 'package:immich_mobile/extensions/translate_extensions.dart';
@@ -472,7 +473,7 @@ class _AlbumList extends StatelessWidget {
472473

473474
final bool isLoading;
474475
final String? error;
475-
final List albums;
476+
final List<Album> albums;
476477
final String? userId;
477478

478479
@override
@@ -543,7 +544,7 @@ class _AlbumList extends StatelessWidget {
543544
)} • ${album.ownerId != userId ? 'shared_by_user'.t(
544545
context: context,
545546
args: {
546-
'user': album.ownerId,
547+
'user': album.ownerName,
547548
},
548549
) : 'owned'.t(context: context)}',
549550
overflow: TextOverflow.ellipsis,

mobile/lib/widgets/common/immich_app_bar.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:auto_route/auto_route.dart';
22
import 'package:easy_localization/easy_localization.dart';
3+
import 'package:flutter/foundation.dart';
34
import 'package:flutter/material.dart';
45
import 'package:flutter_svg/svg.dart';
56
import 'package:hooks_riverpod/hooks_riverpod.dart';
@@ -184,11 +185,11 @@ class ImmichAppBar extends ConsumerWidget implements PreferredSizeWidget {
184185
child: action,
185186
),
186187
),
187-
// if (kDebugMode || kProfileMode)
188-
IconButton(
189-
icon: const Icon(Icons.science_rounded),
190-
onPressed: () => context.pushRoute(const FeatInDevRoute()),
191-
),
188+
if (kDebugMode || kProfileMode)
189+
IconButton(
190+
icon: const Icon(Icons.science_rounded),
191+
onPressed: () => context.pushRoute(const FeatInDevRoute()),
192+
),
192193
if (isCasting)
193194
Padding(
194195
padding: const EdgeInsets.only(right: 12),

0 commit comments

Comments
 (0)