responsive home_page

This commit is contained in:
Dr-Blank 2024-05-08 21:25:06 -04:00
parent a720c977c2
commit ebc14a0448
No known key found for this signature in database
GPG key ID: 7452CC63F210A266
9 changed files with 171 additions and 85 deletions

View file

@ -20,11 +20,17 @@ class CoverImage extends _$CoverImage {
Stream<Uint8List> build(LibraryItem libraryItem) async* {
final api = ref.watch(authenticatedApiProvider);
// ! artifical delay for testing
// await Future.delayed(const Duration(seconds: 2));
// try to get the image from the cache
final file = await imageCacheManager.getFileFromCache(libraryItem.id);
if (file != null) {
// if the image is in the cache, yield it
debugPrint(
'cover image found in cache for ${libraryItem.id} at ${file.file.path}',
);
yield await file.file.readAsBytes();
// return if no need to fetch from the server
if (libraryItem.updatedAt.isBefore(await file.file.lastModified())) {
@ -39,7 +45,7 @@ class CoverImage extends _$CoverImage {
// check if the image is in the cache
final coverImage = await api.items.getCover(
libraryItemId: libraryItem.id,
parameters: const GetImageReqParams(width: 500),
parameters: const GetImageReqParams(width: 1000),
);
// save the image to the cache
final newFile = await imageCacheManager.putFile(