Skip to content

Commit

Permalink
Improve file history navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Nov 21, 2023
1 parent 8541bfe commit 768d68f
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions src/PicView/ChangeImage/FileHistory.cs
Expand Up @@ -199,11 +199,28 @@ internal async Task NextAsync()
else
{
index++;
if (index >= MaxCount) return;
if (index >= MaxCount)
return;
}

if (_fileHistory[index] == Navigation.Pics[Navigation.FolderIndex])
if (Navigation.Pics.Contains(_fileHistory[index]))
{
if (_fileHistory[index] == Navigation.Pics[Navigation.FolderIndex])
{
return;
}
// If the gallery is open, deselect current index
if (UC.GetPicGallery is not null)
{
await UC.GetPicGallery.Dispatcher.InvokeAsync(() =>
{
UC.GetPicGallery.Scroller.CanContentScroll = true; // Disable animations
// Deselect current item
GalleryNavigation.SetSelected(GalleryNavigation.SelectedGalleryItem, false);
GalleryNavigation.SetSelected(Navigation.FolderIndex, false);
});
}
await LoadPic.LoadPicAtIndexAsync(Navigation.Pics.IndexOf(_fileHistory[index])).ConfigureAwait(false);
return;
}

Expand Down Expand Up @@ -232,8 +249,24 @@ internal async Task PrevAsync()
}
}

if (_fileHistory[index] == Navigation.Pics[Navigation.FolderIndex])
if (Navigation.Pics.Contains(_fileHistory[index]))
{
if (_fileHistory[index] == Navigation.Pics[Navigation.FolderIndex])
{
return;
}
// If the gallery is open, deselect current index
if (UC.GetPicGallery is not null)
{
await UC.GetPicGallery.Dispatcher.InvokeAsync(() =>
{
UC.GetPicGallery.Scroller.CanContentScroll = true; // Disable animations
// Deselect current item
GalleryNavigation.SetSelected(GalleryNavigation.SelectedGalleryItem, false);
GalleryNavigation.SetSelected(Navigation.FolderIndex, false);
});
}
await LoadPic.LoadPicAtIndexAsync(Navigation.Pics.IndexOf(_fileHistory[index])).ConfigureAwait(false);
return;
}

Expand Down

0 comments on commit 768d68f

Please sign in to comment.