Przeglądaj źródła

Fix duplicate photo bug in iOS

Vishnu Mohandas 5 lat temu
rodzic
commit
2d3c821932
2 zmienionych plików z 13 dodań i 2 usunięć
  1. 2 2
      lib/ui/detail_page.dart
  2. 11 0
      lib/ui/gallery.dart

+ 2 - 2
lib/ui/detail_page.dart

@@ -35,8 +35,8 @@ class _DetailPageState extends State<DetailPage> {
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
     Logger().i("Opening " +
     Logger().i("Opening " +
-        _photos[_selectedIndex].title +
-        ", " +
+        _photos[_selectedIndex].toString() +
+        ". " +
         _selectedIndex.toString() +
         _selectedIndex.toString() +
         " / " +
         " / " +
         _photos.length.toString() +
         _photos.length.toString() +

+ 11 - 0
lib/ui/gallery.dart

@@ -40,6 +40,7 @@ class _GalleryState extends State<Gallery> {
     // TODO: Investigate reason for multiple rebuilds on selection change
     // TODO: Investigate reason for multiple rebuilds on selection change
     _photos = widget.photos;
     _photos = widget.photos;
     _selectedPhotos = widget.selectedPhotos;
     _selectedPhotos = widget.selectedPhotos;
+    _deduplicatePhotos();
     _collatePhotos();
     _collatePhotos();
 
 
     return ListView.builder(
     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() {
   void _collatePhotos() {
     final dailyPhotos = List<Photo>();
     final dailyPhotos = List<Photo>();
     final collatedPhotos = List<List<Photo>>();
     final collatedPhotos = List<List<Photo>>();