Refactor RunPlayHistory to optimize play retrieval logic and enhance StoragePanelSkeleton accessibility
Updated the RunPlayHistory class to improve the logic for retrieving the latest play by using LINQ's Max method, ensuring that empty play lists are handled correctly. Additionally, modified the StoragePanelSkeleton component to replace the div with an output element for better accessibility, allowing screen readers to recognize the loading status more effectively.
This commit is contained in:
@@ -26,12 +26,12 @@ public sealed class RunPlayHistory
|
||||
DateTimeOffset? last = null;
|
||||
foreach (var showId in ShowsOf(element))
|
||||
{
|
||||
if (!_byShow.TryGetValue(showId, out var plays))
|
||||
if (!_byShow.TryGetValue(showId, out var plays) || plays.Count == 0)
|
||||
continue;
|
||||
|
||||
foreach (var play in plays)
|
||||
if (last is null || play > last)
|
||||
last = play;
|
||||
var latest = plays.Max();
|
||||
if (last is null || latest > last)
|
||||
last = latest;
|
||||
}
|
||||
|
||||
return last;
|
||||
|
||||
Reference in New Issue
Block a user