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:
sh0ckR6 2021-09-07 16:54:21 -04:00
parent 87434333d2
commit b8a1ebb786
No known key found for this signature in database
GPG Key ID: 701938030071AF85
3 changed files with 13 additions and 7 deletions

View File

@ -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());
};

View File

@ -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());
}
}
}

View File

@ -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);
});
});