From d0305bd07671d53b57d205b55619e4a581339984 Mon Sep 17 00:00:00 2001 From: bobo liu Date: Fri, 15 Dec 2023 16:39:49 +0800 Subject: [PATCH] tweaks to handle more galleries --- lib/src/pages/download/download_base_page.dart | 2 +- lib/src/service/archive_download_service.dart | 11 ++++++----- lib/src/service/gallery_download_service.dart | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/src/pages/download/download_base_page.dart b/lib/src/pages/download/download_base_page.dart index fc60398f..6365acc4 100644 --- a/lib/src/pages/download/download_base_page.dart +++ b/lib/src/pages/download/download_base_page.dart @@ -217,7 +217,7 @@ class _GroupListState extends State> { controller: scrollController, padding: const EdgeInsets.only(bottom: 80), itemCount: widget.elements.length + widget.groups.length, - cacheExtent: 6000, + cacheExtent: 20, itemBuilder: (BuildContext context, int index) { int remainingCount = index; int groupIndex = 0; diff --git a/lib/src/service/archive_download_service.dart b/lib/src/service/archive_download_service.dart index 3460c936..952c3114 100644 --- a/lib/src/service/archive_download_service.dart +++ b/lib/src/service/archive_download_service.dart @@ -335,11 +335,11 @@ class ArchiveDownloadService extends GetxController with GridBasePageServiceMixi continue; } - _initArchiveInMemory(archive); + _initArchiveInMemory(archive, sort: false); restoredCount++; } - + _sortArchives(); return restoredCount; } @@ -697,8 +697,9 @@ class ArchiveDownloadService extends GetxController with GridBasePageServiceMixi List archives = await appDb.selectArchives().get(); for (ArchiveDownloadedData archive in archives) { - _initArchiveInMemory(archive); + _initArchiveInMemory(archive, sort: false); } + _sortArchives(); } Future _initArchiveInfo(ArchiveDownloadedData archive) async { @@ -775,7 +776,7 @@ class ArchiveDownloadService extends GetxController with GridBasePageServiceMixi // MEMORY - void _initArchiveInMemory(ArchiveDownloadedData archive) { + void _initArchiveInMemory(ArchiveDownloadedData archive, {bool sort = true}) { if (!allGroups.contains(archive.groupName ?? 'default'.tr)) { allGroups.add(archive.groupName ?? 'default'.tr); } @@ -794,7 +795,7 @@ class ArchiveDownloadService extends GetxController with GridBasePageServiceMixi group: archive.groupName ?? 'default'.tr, ); - _sortArchives(); + if (sort) _sortArchives(); update([galleryCountChangedId, '$archiveStatusId::::${archive.gid}']); } diff --git a/lib/src/service/gallery_download_service.dart b/lib/src/service/gallery_download_service.dart index 9ea70c39..5420eb20 100644 --- a/lib/src/service/gallery_download_service.dart +++ b/lib/src/service/gallery_download_service.dart @@ -431,11 +431,11 @@ class GalleryDownloadService extends GetxController with GridBasePageServiceMixi continue; } - _initGalleryInfoInMemory(gallery, images: images); + _initGalleryInfoInMemory(gallery, images: images, sort: false); restoredCount++; } - + _sortGallerys(); return restoredCount; }