Fix duplicate photo bug in iOS
This commit is contained in:
parent
436b916911
commit
2d3c821932
2 changed files with 13 additions and 2 deletions
|
@ -35,8 +35,8 @@ class _DetailPageState extends State<DetailPage> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Logger().i("Opening " +
|
||||
_photos[_selectedIndex].title +
|
||||
", " +
|
||||
_photos[_selectedIndex].toString() +
|
||||
". " +
|
||||
_selectedIndex.toString() +
|
||||
" / " +
|
||||
_photos.length.toString() +
|
||||
|
|
|
@ -40,6 +40,7 @@ class _GalleryState extends State<Gallery> {
|
|||
// TODO: Investigate reason for multiple rebuilds on selection change
|
||||
_photos = widget.photos;
|
||||
_selectedPhotos = widget.selectedPhotos;
|
||||
_deduplicatePhotos();
|
||||
_collatePhotos();
|
||||
|
||||
return ListView.builder(
|
||||
|
@ -136,6 +137,16 @@ class _GalleryState extends State<Gallery> {
|
|||
);
|
||||
}
|
||||
|
||||
void _deduplicatePhotos() {
|
||||
for (int index = 1; index < _photos.length; index++) {
|
||||
final current = _photos[index], previous = _photos[index - 1];
|
||||
if (current.localId == previous.localId) {
|
||||
_photos.removeAt(index);
|
||||
index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _collatePhotos() {
|
||||
final dailyPhotos = List<Photo>();
|
||||
final collatedPhotos = List<List<Photo>>();
|
||||
|
|
Loading…
Add table
Reference in a new issue