mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 23:53:51 +09:00
Fix webexception due to invalid user ids
This commit is contained in:
@ -3,12 +3,16 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Overlays.Chat;
|
using osu.Game.Overlays.Chat;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -71,18 +75,19 @@ namespace osu.Game.Tests.Visual
|
|||||||
chatTabControl.OnRequestLeave += chat => chatTabControl.RemoveItem(chat);
|
chatTabControl.OnRequestLeave += chat => chatTabControl.RemoveItem(chat);
|
||||||
chatTabControl.Current.ValueChanged += chat => currentText.Text = "Currently selected chat: " + chat.ToString();
|
chatTabControl.Current.ValueChanged += chat => currentText.Text = "Currently selected chat: " + chat.ToString();
|
||||||
|
|
||||||
AddStep("Add random user", () => addUser(RNG.Next(100000), RNG.Next().ToString()));
|
AddStep("Add random user", addRandomUser);
|
||||||
AddRepeatStep("3 random users", () => addUser(RNG.Next(100000), RNG.Next().ToString()), 3);
|
AddRepeatStep("Add 3 random users", addRandomUser, 3);
|
||||||
AddStep("Add random channel", () => addChannel(RNG.Next().ToString()));
|
AddStep("Add random channel", () => addChannel(RNG.Next().ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addUser(long id, string name)
|
private List<User> users;
|
||||||
|
|
||||||
|
private void addRandomUser()
|
||||||
{
|
{
|
||||||
chatTabControl.AddItem(new Channel(new User
|
if (users == null || users.Count == 0)
|
||||||
{
|
return;
|
||||||
Id = id,
|
|
||||||
Username = name
|
chatTabControl.AddItem(new Channel(users[RNG.Next(0, users.Count - 1)]));
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addChannel(string name)
|
private void addChannel(string name)
|
||||||
@ -92,5 +97,14 @@ namespace osu.Game.Tests.Visual
|
|||||||
Name = name
|
Name = name
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(IAPIProvider api)
|
||||||
|
{
|
||||||
|
GetUsersRequest req = new GetUsersRequest();
|
||||||
|
req.Success += list => users = list.Select(e => e.User).ToList();
|
||||||
|
|
||||||
|
api.Queue(req);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user