Browse Source

Remove excess variable

Ruben 1 năm trước cách đây
mục cha
commit
e5ed85c61e

+ 1 - 1
src/PicView.Avalonia/Navigation/ImageIterator.cs

@@ -635,7 +635,7 @@ public sealed class ImageIterator : IDisposable
                 }
                 else
                 {
-                    UpdateImage.LoadingPreview(_vm, index, CurrentIndex);
+                    UpdateImage.LoadingPreview(_vm, index);
                 }
             }
         });

+ 2 - 28
src/PicView.Avalonia/Navigation/UpdateImage.cs

@@ -154,13 +154,8 @@ public static class UpdateImage
         vm.PlatformService.StopTaskbarProgress();
     }
 
-    public static void LoadingPreview(MainViewModel vm, int index, int currentIndex)
+    public static void LoadingPreview(MainViewModel vm, int index)
     {
-        if (index != currentIndex)
-        {
-            return;
-        }
-
         SetTitleHelper.SetLoadingTitle(vm);
         vm.SelectedGalleryItemIndex = index;
         if (SettingsHelper.Settings.Gallery.IsBottomGalleryShown)
@@ -171,35 +166,14 @@ public static class UpdateImage
         using var image = new MagickImage();
         image.Ping(vm.ImageIterator.ImagePaths[index]);
         var thumb = image.GetExifProfile()?.CreateThumbnail();
-        if (thumb is null)
-        {
-            if (index == currentIndex)
-            {
-                vm.IsLoading = true;
-                vm.ImageSource = null;
-            }
 
-            return;
-        }
-
-        var byteArray = thumb.ToByteArray();
+        var byteArray = thumb?.ToByteArray();
         if (byteArray is null)
         {
-            if (index == currentIndex)
-            {
-                vm.IsLoading = true;
-                vm.ImageSource = null;
-            }
-
             return;
         }
 
         var stream = new MemoryStream(byteArray);
-        if (index != currentIndex)
-        {
-            return;
-        }
-
         vm.ImageSource = new Bitmap(stream);
         vm.ImageType = ImageType.Bitmap;
     }