Allow DrawableAvatar to accept an IUser for now

This commit is contained in:
Dean Herbert 2022-09-13 16:54:03 +09:00
parent d251c0b2ac
commit ac58c222b9

View File

@ -14,13 +14,13 @@ namespace osu.Game.Users.Drawables
[LongRunningLoad]
public class DrawableAvatar : Sprite
{
private readonly APIUser user;
private readonly IUser user;
/// <summary>
/// A simple, non-interactable avatar sprite for the specified user.
/// </summary>
/// <param name="user">The user. A null value will get a placeholder avatar.</param>
public DrawableAvatar(APIUser user = null)
public DrawableAvatar(IUser user = null)
{
this.user = user;
@ -33,10 +33,10 @@ namespace osu.Game.Users.Drawables
[BackgroundDependencyLoader]
private void load(LargeTextureStore textures)
{
if (user != null && user.Id > 1)
if (user != null && user.OnlineID > 1)
// TODO: The fallback here should not need to exist. Users should be looked up and populated via UserLookupCache or otherwise
// in remaining cases where this is required (chat tabs, local leaderboard), at which point this should be removed.
Texture = textures.Get(user.AvatarUrl ?? $@"https://a.ppy.sh/{user.Id}");
Texture = textures.Get((user as APIUser)?.AvatarUrl ?? $@"https://a.ppy.sh/{user.OnlineID}");
Texture ??= textures.Get(@"Online/avatar-guest");
}