mirror of
https://github.com/ppy/osu
synced 2025-01-09 23:59:44 +00:00
Hide Popover after failed password attempt
Instead of throwing an error, just close the popover and let the user continue
This commit is contained in:
parent
87434333d2
commit
b8a1ebb786
@ -87,7 +87,8 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
|
||||
currentJoinRoomRequest.Failure += exception =>
|
||||
{
|
||||
if (!(exception is OperationCanceledException))
|
||||
// provide error output if the operation wasn't canceled and the error doesn't stem from an invalid password
|
||||
if (!(exception is OperationCanceledException) && !((APIException)exception).Message.Equals("Invalid room password", StringComparison.Ordinal))
|
||||
Logger.Log($"Failed to join room: {exception}", level: LogLevel.Important);
|
||||
onError?.Invoke(exception.ToString());
|
||||
};
|
||||
|
@ -178,7 +178,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
{
|
||||
private readonly Room room;
|
||||
|
||||
public Action<Room, string> JoinRequested;
|
||||
public Action<Room, string, Action<Room>, Action<string>> JoinRequested;
|
||||
|
||||
public PasswordEntryPopover(Room room)
|
||||
{
|
||||
@ -186,6 +186,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
}
|
||||
|
||||
private OsuPasswordTextBox passwordTextbox;
|
||||
private TriangleButton joinButton;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
@ -201,15 +202,17 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
passwordTextbox = new OsuPasswordTextBox
|
||||
{
|
||||
Width = 200,
|
||||
PlaceholderText = "password",
|
||||
},
|
||||
new TriangleButton
|
||||
joinButton = new TriangleButton
|
||||
{
|
||||
Width = 80,
|
||||
Text = "Join Room",
|
||||
Action = () => JoinRequested?.Invoke(room, passwordTextbox.Text)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
joinButton.Action = () => JoinRequested?.Invoke(room, passwordTextbox.Text, null, _ => this.HidePopover());
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -217,7 +220,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
base.LoadComplete();
|
||||
|
||||
Schedule(() => GetContainingInputManager().ChangeFocus(passwordTextbox));
|
||||
passwordTextbox.OnCommit += (_, __) => JoinRequested?.Invoke(room, passwordTextbox.Text);
|
||||
passwordTextbox.OnCommit += (_, __) => JoinRequested?.Invoke(room, passwordTextbox.Text, null, _ => this.HidePopover());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
popoverContainer.HidePopover();
|
||||
}
|
||||
|
||||
public void Join(Room room, string password) => Schedule(() =>
|
||||
public void Join(Room room, string password, Action<Room> onSuccess = null, Action<string> onFailure = null) => Schedule(() =>
|
||||
{
|
||||
if (joiningRoomOperation != null)
|
||||
return;
|
||||
@ -302,10 +302,12 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
Open(room);
|
||||
joiningRoomOperation?.Dispose();
|
||||
joiningRoomOperation = null;
|
||||
}, _ =>
|
||||
onSuccess?.Invoke(room);
|
||||
}, error =>
|
||||
{
|
||||
joiningRoomOperation?.Dispose();
|
||||
joiningRoomOperation = null;
|
||||
onFailure?.Invoke(error);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user