From 5cbfaf3589413c5be4292f97dd91c78b13059534 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Nov 2020 20:19:38 +0900 Subject: [PATCH] Revert "Add (temporary) local user cache to avoid re-querying API each display" This reverts commit 4e17634ee27ab7dfc33753c1750d8f91e6e2b206. --- .../Dashboard/CurrentlyPlayingDisplay.cs | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs b/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs index b461da4476..d71e582c05 100644 --- a/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs +++ b/osu.Game/Overlays/Dashboard/CurrentlyPlayingDisplay.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using osu.Framework.Allocation; @@ -44,9 +43,6 @@ namespace osu.Game.Overlays.Dashboard [Resolved] private IAPIProvider api { get; set; } - // temporary, should be game-global but i don't want to add more manager classes for now. - private static readonly Dictionary user_cache = new Dictionary(); - protected override void LoadComplete() { base.LoadComplete(); @@ -57,24 +53,15 @@ namespace osu.Game.Overlays.Dashboard switch (e.Action) { case NotifyCollectionChangedAction.Add: - foreach (int userId in e.NewItems.OfType()) + foreach (var u in e.NewItems.OfType()) { - if (user_cache.TryGetValue(userId, out var user)) + var request = new GetUserRequest(u); + request.Success += user => Schedule(() => { - addUser(user); - continue; - } - - var request = new GetUserRequest(userId); - request.Success += u => Schedule(() => addUser(u)); + if (playingUsers.Contains((int)user.Id)) + userFlow.Add(createUserPanel(user)); + }); api.Queue(request); - - void addUser(User u) - { - user_cache[userId] = u; - if (playingUsers.Contains(userId)) - userFlow.Add(createUserPanel(u)); - } } break;