Fix collection dropdown potentially overwriting value change with schedule hotfix

This commit is contained in:
Dean Herbert 2022-08-23 17:33:09 +09:00
parent 9a579871c0
commit db004c9d9f
1 changed files with 8 additions and 1 deletions

View File

@ -75,7 +75,14 @@ private void collectionsChanged(IRealmCollection<BeatmapCollection> collections,
// changes. It's not great but honestly the whole dropdown menu structure isn't great. This needs to be fixed, but I'll issue
// a warning that it's going to be a frustrating journey.
Current.Value = allBeatmaps;
Schedule(() => Current.Value = filters.SingleOrDefault(f => f.Collection != null && f.Collection.ID == selectedItem?.ID) ?? filters[0]);
Schedule(() =>
{
// current may have changed before the scheduled call is run.
if (Current.Value != allBeatmaps)
return;
Current.Value = filters.SingleOrDefault(f => f.Collection != null && f.Collection.ID == selectedItem?.ID) ?? filters[0];
});
// Trigger a re-filter if the current item was in the change set.
if (selectedItem != null && changes != null)