Skip to content

Commit 0ee8a1a

Browse files
committed
Use userId instead of ownerId
1 parent 8899055 commit 0ee8a1a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

mobile/lib/providers/image/immich_local_thumbnail_provider.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ class ImmichLocalThumbnailProvider
2020
final int width;
2121
final CacheManager? cacheManager;
2222
final Logger log = Logger("ImmichLocalThumbnailProvider");
23+
final String? userId;
2324

2425
ImmichLocalThumbnailProvider({
2526
required this.asset,
2627
this.height = 256,
2728
this.width = 256,
2829
this.cacheManager,
30+
this.userId,
2931
}) : assert(asset.local != null, 'Only usable when asset.local is set');
3032

3133
/// Converts an [ImageProvider]'s settings plus an [ImageConfiguration] to a key
@@ -58,7 +60,7 @@ class ImmichLocalThumbnailProvider
5860
CacheManager cache,
5961
ImageDecoderCallback decode,
6062
) async* {
61-
final cacheKey = '${assetData.ownerId}-${assetData.id}-${width}x$height';
63+
final cacheKey = '$userId-${assetData.id}-${width}x$height';
6264
final fileFromCache = await cache.getFileFromCache(cacheKey);
6365
if (fileFromCache != null) {
6466
try {

mobile/lib/widgets/common/immich_thumbnail.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ import 'dart:typed_data';
22

33
import 'package:flutter/material.dart';
44
import 'package:flutter_hooks/flutter_hooks.dart';
5+
import 'package:hooks_riverpod/hooks_riverpod.dart';
56
import 'package:immich_mobile/providers/image/immich_local_thumbnail_provider.dart';
67
import 'package:immich_mobile/providers/image/immich_remote_thumbnail_provider.dart';
78
import 'package:immich_mobile/entities/asset.entity.dart';
89
import 'package:immich_mobile/utils/hooks/blurhash_hook.dart';
910
import 'package:immich_mobile/widgets/common/immich_image.dart';
1011
import 'package:immich_mobile/widgets/common/thumbhash_placeholder.dart';
1112
import 'package:octo_image/octo_image.dart';
13+
import 'package:immich_mobile/providers/user.provider.dart';
1214

13-
class ImmichThumbnail extends HookWidget {
15+
class ImmichThumbnail extends HookConsumerWidget {
1416
const ImmichThumbnail({
1517
this.asset,
1618
this.width = 250,
@@ -31,6 +33,7 @@ class ImmichThumbnail extends HookWidget {
3133
static ImageProvider imageProvider({
3234
Asset? asset,
3335
String? assetId,
36+
String? userId,
3437
int thumbnailSize = 256,
3538
}) {
3639
if (asset == null && assetId == null) {
@@ -48,6 +51,7 @@ class ImmichThumbnail extends HookWidget {
4851
asset: asset,
4952
height: thumbnailSize,
5053
width: thumbnailSize,
54+
userId: userId,
5155
);
5256
} else {
5357
return ImmichRemoteThumbnailProvider(
@@ -59,8 +63,10 @@ class ImmichThumbnail extends HookWidget {
5963
}
6064

6165
@override
62-
Widget build(BuildContext context) {
66+
Widget build(BuildContext context, WidgetRef ref) {
6367
Uint8List? blurhash = useBlurHashRef(asset).value;
68+
final userId = ref.watch(currentUserProvider)?.id;
69+
6470
if (asset == null) {
6571
return Container(
6672
color: Colors.grey,
@@ -79,6 +85,7 @@ class ImmichThumbnail extends HookWidget {
7985
octoSet: blurHashOrPlaceholder(blurhash),
8086
image: ImmichThumbnail.imageProvider(
8187
asset: asset,
88+
userId: userId,
8289
),
8390
width: width,
8491
height: height,

0 commit comments

Comments
 (0)