1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:07:44 +08:00

Simplify invalidation logic

The only case where this was checking is guaranteed by realm to only be called once.
This commit is contained in:
Dean Herbert 2023-12-18 20:10:31 +09:00
parent 87b7699fcc
commit 6fa1f5ef9b
No known key found for this signature in database

View File

@ -168,7 +168,7 @@ namespace osu.Game.Screens.Select
applyActiveCriteria(false); applyActiveCriteria(false);
if (loadedTestBeatmaps) if (loadedTestBeatmaps)
invalidateAfterChange(true); invalidateAfterChange();
// Restore selection // Restore selection
if (selectedBeatmapBefore != null && newRoot.BeatmapSetsByID.TryGetValue(selectedBeatmapBefore.BeatmapSet!.ID, out var newSelectionCandidates)) if (selectedBeatmapBefore != null && newRoot.BeatmapSetsByID.TryGetValue(selectedBeatmapBefore.BeatmapSet!.ID, out var newSelectionCandidates))
@ -298,7 +298,7 @@ namespace osu.Game.Screens.Select
removeBeatmapSet(id); removeBeatmapSet(id);
} }
invalidateAfterChange(!BeatmapSetsLoaded); invalidateAfterChange();
BeatmapSetsLoaded = true; BeatmapSetsLoaded = true;
return; return;
} }
@ -349,7 +349,7 @@ namespace osu.Game.Screens.Select
} }
} }
invalidateAfterChange(!BeatmapSetsLoaded); invalidateAfterChange();
} }
private void beatmapsChanged(IRealmCollection<BeatmapInfo> sender, ChangeSet? changes) private void beatmapsChanged(IRealmCollection<BeatmapInfo> sender, ChangeSet? changes)
@ -378,7 +378,7 @@ namespace osu.Game.Screens.Select
} }
if (changed) if (changed)
invalidateAfterChange(true); invalidateAfterChange();
} }
private IQueryable<BeatmapSetInfo> getBeatmapSets(Realm realm) => realm.All<BeatmapSetInfo>().Where(s => !s.DeletePending && !s.Protected); private IQueryable<BeatmapSetInfo> getBeatmapSets(Realm realm) => realm.All<BeatmapSetInfo>().Where(s => !s.DeletePending && !s.Protected);
@ -386,7 +386,7 @@ namespace osu.Game.Screens.Select
public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet) => Schedule(() => public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet) => Schedule(() =>
{ {
removeBeatmapSet(beatmapSet.ID); removeBeatmapSet(beatmapSet.ID);
invalidateAfterChange(true); invalidateAfterChange();
}); });
private void removeBeatmapSet(Guid beatmapSetID) private void removeBeatmapSet(Guid beatmapSetID)
@ -409,7 +409,7 @@ namespace osu.Game.Screens.Select
public void UpdateBeatmapSet(BeatmapSetInfo beatmapSet) => Schedule(() => public void UpdateBeatmapSet(BeatmapSetInfo beatmapSet) => Schedule(() =>
{ {
updateBeatmapSet(beatmapSet); updateBeatmapSet(beatmapSet);
invalidateAfterChange(true); invalidateAfterChange();
}); });
private void updateBeatmapSet(BeatmapSetInfo beatmapSet) private void updateBeatmapSet(BeatmapSetInfo beatmapSet)
@ -752,14 +752,13 @@ namespace osu.Game.Screens.Select
} }
} }
private void invalidateAfterChange(bool invokeSetsChangedEvent) private void invalidateAfterChange()
{ {
itemsCache.Invalidate(); itemsCache.Invalidate();
if (!Scroll.UserScrolling) if (!Scroll.UserScrolling)
ScrollToSelected(true); ScrollToSelected(true);
if (invokeSetsChangedEvent)
BeatmapSetsChanged?.Invoke(); BeatmapSetsChanged?.Invoke();
} }