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 => 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); Logger.Log($"Failed to join room: {exception}", level: LogLevel.Important);
onError?.Invoke(exception.ToString()); onError?.Invoke(exception.ToString());
}; };

View File

@ -178,7 +178,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
{ {
private readonly Room room; private readonly Room room;
public Action<Room, string> JoinRequested; public Action<Room, string, Action<Room>, Action<string>> JoinRequested;
public PasswordEntryPopover(Room room) public PasswordEntryPopover(Room room)
{ {
@ -186,6 +186,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
} }
private OsuPasswordTextBox passwordTextbox; private OsuPasswordTextBox passwordTextbox;
private TriangleButton joinButton;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
@ -201,15 +202,17 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
passwordTextbox = new OsuPasswordTextBox passwordTextbox = new OsuPasswordTextBox
{ {
Width = 200, Width = 200,
PlaceholderText = "password",
}, },
new TriangleButton joinButton = new TriangleButton
{ {
Width = 80, Width = 80,
Text = "Join Room", Text = "Join Room",
Action = () => JoinRequested?.Invoke(room, passwordTextbox.Text)
} }
} }
}; };
joinButton.Action = () => JoinRequested?.Invoke(room, passwordTextbox.Text, null, _ => this.HidePopover());
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -217,7 +220,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
base.LoadComplete(); base.LoadComplete();
Schedule(() => GetContainingInputManager().ChangeFocus(passwordTextbox)); 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(); 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) if (joiningRoomOperation != null)
return; return;
@ -302,10 +302,12 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
Open(room); Open(room);
joiningRoomOperation?.Dispose(); joiningRoomOperation?.Dispose();
joiningRoomOperation = null; joiningRoomOperation = null;
}, _ => onSuccess?.Invoke(room);
}, error =>
{ {
joiningRoomOperation?.Dispose(); joiningRoomOperation?.Dispose();
joiningRoomOperation = null; joiningRoomOperation = null;
onFailure?.Invoke(error);
}); });
}); });