kopia lustrzana https://gitlab.com/mysocialportal/relatica
Fix gallery update bugs with deleted images and overpaging
rodzic
605e9682e6
commit
e0926a50d2
|
|
@ -12,7 +12,7 @@ class GalleryService extends ChangeNotifier {
|
|||
static const IMAGES_PER_PAGE = 50;
|
||||
final _galleries = <String, GalleryData>{};
|
||||
final _galleryPages = <String, List<PagingData>>{};
|
||||
final _images = <String, Set<ImageEntry>>{};
|
||||
final _images = <String, List<ImageEntry>>{};
|
||||
var _loaded = false;
|
||||
|
||||
final Profile profile;
|
||||
|
|
@ -92,11 +92,13 @@ class GalleryService extends ChangeNotifier {
|
|||
if (pages.isEmpty) {
|
||||
pages.add(PagingData(offset: 0, limit: IMAGES_PER_PAGE));
|
||||
} else if (withNextPage) {
|
||||
final offset = pages.last.offset! + 1;
|
||||
final offset = pages.last.offset! + IMAGES_PER_PAGE;
|
||||
pages.add(PagingData(offset: offset, limit: IMAGES_PER_PAGE));
|
||||
}
|
||||
|
||||
final imageSet = _images.putIfAbsent(galleryName, () => {});
|
||||
final imageSet = nextPageOnly
|
||||
? _images.putIfAbsent(galleryName, () => []).toSet()
|
||||
: <ImageEntry>{};
|
||||
|
||||
final pagesToUse = nextPageOnly ? [pages.last] : pages;
|
||||
for (final page in pagesToUse) {
|
||||
|
|
@ -106,8 +108,12 @@ class GalleryService extends ChangeNotifier {
|
|||
return result.errorCast();
|
||||
}
|
||||
|
||||
print(result.value.length);
|
||||
|
||||
imageSet.addAll(result.value);
|
||||
}
|
||||
|
||||
_images[galleryName] = imageSet.toList();
|
||||
notifyListeners();
|
||||
return Result.ok(imageSet.toList(growable: false));
|
||||
}
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue