Refactor UChapDataPreloadExtensions to improve image byte retrieval logic

This commit is contained in:
Moustapha Kodjo Amadou 2025-07-09 14:49:42 +01:00
parent e9bbd2e1e3
commit debbb26dbf
2 changed files with 5 additions and 5 deletions

BIN
assets/transparent.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -48,7 +48,7 @@ extension UChapDataPreloadExtensions on UChapDataPreload {
Uint8List? imageBytes;
if (archiveImage != null) {
imageBytes = archiveImage;
} else if (isLocale!) {
} else if (isLocale == true && directory != null && index != null) {
imageBytes = File(
p.join(directory!.path, "${padIndex(index!)}.jpg"),
).readAsBytesSync();
@ -56,10 +56,10 @@ extension UChapDataPreloadExtensions on UChapDataPreload {
File? cachedImage;
if (pageUrl != null) {
cachedImage = await _getCachedImageFile(pageUrl!.url);
}
if (cachedImage == null) {
await Future.delayed(const Duration(seconds: 3));
cachedImage = await _getCachedImageFile(pageUrl!.url);
if (cachedImage == null) {
await Future.delayed(const Duration(seconds: 3));
cachedImage = await _getCachedImageFile(pageUrl!.url);
}
}
imageBytes = cachedImage?.readAsBytesSync();
}