mirror of
https://github.com/ppy/osu
synced 2024-12-15 11:25:29 +00:00
Merge pull request #765 from peppy/fix-guest-user
Fix guest user being null
This commit is contained in:
commit
14b06f3600
@ -34,7 +34,7 @@ namespace osu.Game.Online.API
|
||||
|
||||
public string Password;
|
||||
|
||||
public Bindable<User> LocalUser = new Bindable<User>();
|
||||
public Bindable<User> LocalUser = new Bindable<User>(createGuestUser());
|
||||
|
||||
public string Token
|
||||
{
|
||||
@ -191,7 +191,7 @@ namespace osu.Game.Online.API
|
||||
req.Perform(this);
|
||||
|
||||
//we could still be in initialisation, at which point we don't want to say we're Online yet.
|
||||
if (LocalUser.Value != null)
|
||||
if (IsLoggedIn)
|
||||
State = APIState.Online;
|
||||
|
||||
failureCount = 0;
|
||||
@ -266,6 +266,8 @@ namespace osu.Game.Online.API
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLoggedIn => LocalUser.Value.Id > 1;
|
||||
|
||||
public void Queue(APIRequest request)
|
||||
{
|
||||
queue.Enqueue(request);
|
||||
@ -295,8 +297,15 @@ namespace osu.Game.Online.API
|
||||
clearCredentials();
|
||||
authentication.Clear();
|
||||
State = APIState.Offline;
|
||||
LocalUser.Value = createGuestUser();
|
||||
}
|
||||
|
||||
private static User createGuestUser() => new User
|
||||
{
|
||||
Username = @"Guest",
|
||||
Id = 1,
|
||||
};
|
||||
|
||||
public void Update()
|
||||
{
|
||||
Scheduler.Update();
|
||||
|
@ -353,7 +353,15 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
var postText = textbox.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(postText) || api.LocalUser.Value == null) return;
|
||||
if (string.IsNullOrEmpty(postText))
|
||||
return;
|
||||
|
||||
if (!api.IsLoggedIn)
|
||||
{
|
||||
currentChannel?.AddNewMessages(new ErrorMessage("Please login to participate in chat!"));
|
||||
textbox.Text = string.Empty;
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentChannel == null) return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user