Fix some web requests retrieving the user too early

This commit is contained in:
Dean Herbert
2020-07-14 13:07:17 +09:00
parent 8411a36a0f
commit 7fe69bb199
8 changed files with 22 additions and 28 deletions

View File

@ -5,6 +5,7 @@ using System;
using Newtonsoft.Json;
using osu.Framework.IO.Network;
using osu.Framework.Logging;
using osu.Game.Users;
namespace osu.Game.Online.API
{
@ -61,6 +62,11 @@ namespace osu.Game.Online.API
protected APIAccess API;
protected WebRequest WebRequest;
/// <summary>
/// The currently logged in user. Note that this will only be populated during <see cref="Perform"/>.
/// </summary>
protected User User { get; private set; }
/// <summary>
/// Invoked on successful completion of an API request.
/// This will be scheduled to the API's internal scheduler (run on update thread automatically).
@ -86,6 +92,7 @@ namespace osu.Game.Online.API
}
API = apiAccess;
User = apiAccess.LocalUser.Value;
if (checkAndScheduleFailure())
return;

View File

@ -4,19 +4,16 @@
using System.Net.Http;
using osu.Framework.IO.Network;
using osu.Game.Online.Chat;
using osu.Game.Users;
namespace osu.Game.Online.API.Requests
{
public class JoinChannelRequest : APIRequest
{
private readonly Channel channel;
private readonly User user;
public JoinChannelRequest(Channel channel, User user)
public JoinChannelRequest(Channel channel)
{
this.channel = channel;
this.user = user;
}
protected override WebRequest CreateWebRequest()
@ -26,6 +23,6 @@ namespace osu.Game.Online.API.Requests
return req;
}
protected override string Target => $@"chat/channels/{channel.Id}/users/{user.Id}";
protected override string Target => $@"chat/channels/{channel.Id}/users/{User.Id}";
}
}

View File

@ -4,19 +4,16 @@
using System.Net.Http;
using osu.Framework.IO.Network;
using osu.Game.Online.Multiplayer;
using osu.Game.Users;
namespace osu.Game.Online.API.Requests
{
public class JoinRoomRequest : APIRequest
{
private readonly Room room;
private readonly User user;
public JoinRoomRequest(Room room, User user)
public JoinRoomRequest(Room room)
{
this.room = room;
this.user = user;
}
protected override WebRequest CreateWebRequest()
@ -26,6 +23,6 @@ namespace osu.Game.Online.API.Requests
return req;
}
protected override string Target => $"rooms/{room.RoomID.Value}/users/{user.Id}";
protected override string Target => $"rooms/{room.RoomID.Value}/users/{User.Id}";
}
}

View File

@ -4,19 +4,16 @@
using System.Net.Http;
using osu.Framework.IO.Network;
using osu.Game.Online.Chat;
using osu.Game.Users;
namespace osu.Game.Online.API.Requests
{
public class LeaveChannelRequest : APIRequest
{
private readonly Channel channel;
private readonly User user;
public LeaveChannelRequest(Channel channel, User user)
public LeaveChannelRequest(Channel channel)
{
this.channel = channel;
this.user = user;
}
protected override WebRequest CreateWebRequest()
@ -26,6 +23,6 @@ namespace osu.Game.Online.API.Requests
return req;
}
protected override string Target => $@"chat/channels/{channel.Id}/users/{user.Id}";
protected override string Target => $@"chat/channels/{channel.Id}/users/{User.Id}";
}
}

View File

@ -4,19 +4,16 @@
using System.Net.Http;
using osu.Framework.IO.Network;
using osu.Game.Online.Multiplayer;
using osu.Game.Users;
namespace osu.Game.Online.API.Requests
{
public class PartRoomRequest : APIRequest
{
private readonly Room room;
private readonly User user;
public PartRoomRequest(Room room, User user)
public PartRoomRequest(Room room)
{
this.room = room;
this.user = user;
}
protected override WebRequest CreateWebRequest()
@ -26,6 +23,6 @@ namespace osu.Game.Online.API.Requests
return req;
}
protected override string Target => $"rooms/{room.RoomID.Value}/users/{user.Id}";
protected override string Target => $"rooms/{room.RoomID.Value}/users/{User.Id}";
}
}