Make BeatmapSetOverlay accept nulls everywhere #2416
Conversation
Can you split this up into multiple PRs or even just multiple commits next time? This is super difficult to go through since so many files are touched. |
How would you split it up? It'd just become a commit per class or class group, at which point it's the same as just reviewing a file at a time. The changes I made are basically the same in each case. Once you start reviewing you'll understand. |
Reviewing one class or class group at a time would make this so much simpler. The avatar change is grouped into all of this, changes to how things are displayed in SuccessRate are grouped into all of this, changes to display and interaction of things like Beatmap in ScoresContainer are grouped into all of this. None of these components have been tested individually, so there's a lot of cases I have to go through to validate the code visually. |
This is one of the reasons I want individual tests per component. Right now the whole overlay is one testable component so that's how I felt it correct to apply updates. |
Cool, sounds like something you should've done then. |
Can do if you'd prefer, though it's a large time investment and the changes made here are pretty straight-forward (just moving logic to a separate method). |
@@ -31,15 +32,25 @@ public BeatmapMetrics Metrics | |||
|
|||
const int rating_range = 10; | |||
|
|||
var ratings = Metrics.Ratings.Skip(1).Take(rating_range); // adjust for API returning weird empty data at 0. | |||
if (metrics == null) |
smoogipoo
Apr 19, 2018
Contributor
So what happens if metrics
is non-null but there are 0 ratings? Won't the else-block fail? Shouldn't this account for this scenario?
So what happens if metrics
is non-null but there are 0 ratings? Won't the else-block fail? Shouldn't this account for this scenario?
@@ -125,6 +120,15 @@ protected override void Update() | |||
|
|||
private void updatePreviewTrack(bool playing) | |||
{ | |||
if (playing && BeatmapSet == null) |
smoogipoo
Apr 19, 2018
Contributor
When is this ever the case? Why do we have random osu!direct play buttons with null beatmap sets? Why are we allowing this?
When is this ever the case? Why do we have random osu!direct play buttons with null beatmap sets? Why are we allowing this?
peppy
Apr 19, 2018
Author
Member
The play button is still being displayed in the interface in the case the interface is loading.
This whole PR makes it possible to pass down a null beatmap in this case and now have the whole interface hidden, as previously.
The play button is still being displayed in the interface in the case the interface is loading.
This whole PR makes it possible to pass down a null beatmap in this case and now have the whole interface hidden, as previously.
clickableArea.Action = () => profile?.ShowUser(avatar.User); | ||
clickableArea.Action = () => | ||
{ | ||
if (avatar.User != null) profile?.ShowUser(avatar.User); |
smoogipoo
Apr 19, 2018
Contributor
avatar can be null
avatar can be null
peppy
Apr 19, 2018
Author
Member
it's set in the ctor
it's set in the ctor
smoogipoo
Apr 19, 2018
Contributor
Set BeatmapSet to null -> Click -> avatar == null
Set BeatmapSet to null -> Click -> avatar == null
peppy
Apr 19, 2018
Author
Member
avatar.User
avatar.User
@@ -47,9 +47,7 @@ public TestCaseBeatmapScoresContainer() | |||
AddStep("scores pack 1", () => scoresContainer.Scores = scores); | |||
AddStep("scores pack 2", () => scoresContainer.Scores = anotherScores); | |||
AddStep("only top score", () => scoresContainer.Scores = new[] { topScore }); | |||
AddStep("remove scores", scoresContainer.CleanAllScores); | |||
AddStep("turn on loading", () => scoresContainer.IsLoading = true); | |||
AddStep("turn off loading", () => scoresContainer.IsLoading = false); |
smoogipoo
Apr 19, 2018
Contributor
So now there is no way to test loading of scores. This needs a test.
So now there is no way to test loading of scores. This needs a test.
peppy
Apr 19, 2018
Author
Member
There is no loading any more. I removed this because it was broken (go check it before this PR).
There is no loading any more. I removed this because it was broken (go check it before this PR).
smoogipoo
Apr 19, 2018
Contributor
Well, sure there is no more IsLoading
property, but the loading animation + retrieval of scores is still there.
Well, sure there is no more IsLoading
property, but the loading animation + retrieval of scores is still there.
|
||
private readonly ScrollContainer scroll; | ||
|
||
private BeatmapSetInfo beatmapSet; | ||
|
||
public BeatmapSetInfo BeatmapSet |
smoogipoo
Apr 19, 2018
Contributor
This is unused. Is there a reason this was made?
This is unused. Is there a reason this was made?
◕‿◕ sure why not |
At very least I think this is a step in the right direction. |
A step forward in usability of
BeatmapSetOverlay
. The default state now matches what you are returned to when displaying anull
BeatmapInfo
.Helps with making #2350 tidy.
BeatmapSetOverlay
hierarchy now acceptsnull
in its settable property.updateInfo
, which is also called from BDL to provide a default state.