don't cache fetch failures for media
This commit is contained in:
parent
0193811993
commit
ad402ff456
1 changed files with 15 additions and 10 deletions
|
|
@ -20,18 +20,23 @@ class MxcImage(final WidgetRef ref, final DownloadMediaRequest request)
|
||||||
MultiFrameImageStreamCompleter(codec: _loadAsync(decode), scale: 1.0);
|
MultiFrameImageStreamCompleter(codec: _loadAsync(decode), scale: 1.0);
|
||||||
|
|
||||||
Future<ui.Codec> _loadAsync(ImageDecoderCallback decode) async {
|
Future<ui.Codec> _loadAsync(ImageDecoderCallback decode) async {
|
||||||
final file = await ref
|
try {
|
||||||
.read(ClientController.provider.notifier)
|
final file = await ref
|
||||||
.downloadMedia(request);
|
.read(ClientController.provider.notifier)
|
||||||
final bytes = await File(file.path).readAsBytes();
|
.downloadMedia(request);
|
||||||
|
final bytes = await File(file.path).readAsBytes();
|
||||||
|
|
||||||
// Flutter can't decode AVIF on Linux/Windows (or older Android/iOS), so we do it ourselves
|
// Flutter can't decode AVIF on Linux/Windows (or older Android/iOS), so we do it ourselves
|
||||||
if (String.fromCharCodes(bytes.skip(4).take(8))
|
if (String.fromCharCodes(bytes.skip(4).take(8))
|
||||||
case "ftypavif" || "ftypavis") {
|
case "ftypavif" || "ftypavis") {
|
||||||
return AvifCodec(await Isolate.run(() => decodeAvif(bytes)));
|
return AvifCodec(await Isolate.run(() => decodeAvif(bytes)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return await decode(await .fromUint8List(bytes));
|
||||||
|
} catch (_) {
|
||||||
|
scheduleMicrotask(() => PaintingBinding.instance.imageCache.evict(this));
|
||||||
|
rethrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
return decode(await .fromUint8List(bytes));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue