Skip to content

Commit

Permalink
Fix issue with unsetting rating of selected images in thumbnail view #…
Browse files Browse the repository at this point in the history
  • Loading branch information
RupertAvery committed Apr 20, 2024
1 parent 0772a39 commit 3175e78
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Diffusion.Toolkit/Controls/ThumbnailView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,25 +399,26 @@ private void RateSelected(int rating)
{
var imageEntries = ThumbnailListView.SelectedItems.Cast<ImageEntry>().ToList();

int? effectiveRating = rating;

if (imageEntries.Count(i => i.Rating == rating) > imageEntries.Count / 2)
{
effectiveRating = null;
}

foreach (var entry in imageEntries)
{
entry.Rating = effectiveRating;

if (entry.Rating == rating)
{
entry.Rating = null;
}
else
{
entry.Rating = rating;
}
if (Model.CurrentImage != null && Model.CurrentImage.Path == entry.Path)
{
Model.CurrentImage.Rating = entry.Rating;
}
}

var ids = imageEntries.Select(x => x.Id).ToList();
DataStore.SetRating(ids, rating);

DataStore.SetRating(ids, effectiveRating);
}
}

Expand Down

0 comments on commit 3175e78

Please sign in to comment.