浏览代码

Remove excess variable

Ruben 1 年之前
父节点
当前提交
e5ed85c61e
共有 2 个文件被更改,包括 3 次插入29 次删除
  1. 1 1
      src/PicView.Avalonia/Navigation/ImageIterator.cs
  2. 2 28
      src/PicView.Avalonia/Navigation/UpdateImage.cs

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

@@ -635,7 +635,7 @@ public sealed class ImageIterator : IDisposable
                 }
                 }
                 else
                 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();
         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);
         SetTitleHelper.SetLoadingTitle(vm);
         vm.SelectedGalleryItemIndex = index;
         vm.SelectedGalleryItemIndex = index;
         if (SettingsHelper.Settings.Gallery.IsBottomGalleryShown)
         if (SettingsHelper.Settings.Gallery.IsBottomGalleryShown)
@@ -171,35 +166,14 @@ public static class UpdateImage
         using var image = new MagickImage();
         using var image = new MagickImage();
         image.Ping(vm.ImageIterator.ImagePaths[index]);
         image.Ping(vm.ImageIterator.ImagePaths[index]);
         var thumb = image.GetExifProfile()?.CreateThumbnail();
         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 (byteArray is null)
         {
         {
-            if (index == currentIndex)
-            {
-                vm.IsLoading = true;
-                vm.ImageSource = null;
-            }
-
             return;
             return;
         }
         }
 
 
         var stream = new MemoryStream(byteArray);
         var stream = new MemoryStream(byteArray);
-        if (index != currentIndex)
-        {
-            return;
-        }
-
         vm.ImageSource = new Bitmap(stream);
         vm.ImageSource = new Bitmap(stream);
         vm.ImageType = ImageType.Bitmap;
         vm.ImageType = ImageType.Bitmap;
     }
     }