mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 04:05:39 -04:00
fix(mobile): stale thumbnail cache (#18351)
* fix(mobile): stale thumbnail cache * Revert height/width usage
This commit is contained in:
parent
9e47093501
commit
2431e04a09
@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:immich_mobile/domain/models/store.model.dart';
|
import 'package:immich_mobile/domain/models/store.model.dart';
|
||||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||||
import 'package:immich_mobile/entities/store.entity.dart';
|
import 'package:immich_mobile/entities/store.entity.dart';
|
||||||
@ -76,39 +75,32 @@ class ImmichImage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final imageProviderInstance = ImmichImage.imageProvider(
|
||||||
|
asset: asset,
|
||||||
|
width: context.width,
|
||||||
|
height: context.height,
|
||||||
|
);
|
||||||
|
|
||||||
return OctoImage(
|
return OctoImage(
|
||||||
fadeInDuration: const Duration(milliseconds: 0),
|
fadeInDuration: const Duration(milliseconds: 0),
|
||||||
fadeOutDuration: const Duration(milliseconds: 200),
|
fadeOutDuration: const Duration(milliseconds: 100),
|
||||||
placeholderBuilder: (context) {
|
placeholderBuilder: (context) {
|
||||||
if (placeholder != null) {
|
if (placeholder != null) {
|
||||||
// Use the gray box placeholder
|
|
||||||
return placeholder!;
|
return placeholder!;
|
||||||
}
|
}
|
||||||
// No placeholder
|
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
},
|
},
|
||||||
image: ImmichImage.imageProvider(
|
image: imageProviderInstance,
|
||||||
asset: asset,
|
|
||||||
width: context.width,
|
|
||||||
height: context.height,
|
|
||||||
),
|
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
fit: fit,
|
fit: fit,
|
||||||
errorBuilder: (context, error, stackTrace) {
|
errorBuilder: (context, error, stackTrace) {
|
||||||
if (error is PlatformException &&
|
imageProviderInstance.evict();
|
||||||
error.code == "The asset not found!") {
|
|
||||||
debugPrint(
|
|
||||||
"Asset ${asset?.localId} does not exist anymore on device!",
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
debugPrint(
|
|
||||||
"Error getting thumb for assetId=${asset?.localId}: $error",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Icon(
|
return Icon(
|
||||||
Icons.image_not_supported_outlined,
|
Icons.image_not_supported_outlined,
|
||||||
color: context.primaryColor,
|
size: 32,
|
||||||
|
color: Colors.red[200],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -77,15 +77,28 @@ class ImmichThumbnail extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final thumbnailProviderInstance = ImmichThumbnail.imageProvider(
|
||||||
|
asset: asset,
|
||||||
|
userId: userId,
|
||||||
|
);
|
||||||
|
|
||||||
|
customErrorBuilder(BuildContext ctx, Object error, StackTrace? stackTrace) {
|
||||||
|
thumbnailProviderInstance.evict();
|
||||||
|
|
||||||
|
final originalErrorWidgetBuilder =
|
||||||
|
blurHashErrorBuilder(blurhash, fit: fit);
|
||||||
|
return originalErrorWidgetBuilder(ctx, error, stackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
return OctoImage.fromSet(
|
return OctoImage.fromSet(
|
||||||
placeholderFadeInDuration: Duration.zero,
|
placeholderFadeInDuration: Duration.zero,
|
||||||
fadeInDuration: Duration.zero,
|
fadeInDuration: Duration.zero,
|
||||||
fadeOutDuration: const Duration(milliseconds: 100),
|
fadeOutDuration: const Duration(milliseconds: 100),
|
||||||
octoSet: blurHashOrPlaceholder(blurhash),
|
octoSet: OctoSet(
|
||||||
image: ImmichThumbnail.imageProvider(
|
placeholderBuilder: blurHashPlaceholderBuilder(blurhash, fit: fit),
|
||||||
asset: asset,
|
errorBuilder: customErrorBuilder,
|
||||||
userId: userId,
|
|
||||||
),
|
),
|
||||||
|
image: thumbnailProviderInstance,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
fit: fit,
|
fit: fit,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user