1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-14 00:53:19 +08:00

Fix crash when the local echo is send to the wrong channel.

This commit is contained in:
miterosan 2018-07-09 21:00:39 +02:00
parent f681ef41ac
commit ec914a5095
2 changed files with 7 additions and 5 deletions

View File

@ -29,7 +29,7 @@ namespace osu.Game.Online.Chat
public readonly Bindable<bool> Joined = new Bindable<bool>(); public readonly Bindable<bool> Joined = new Bindable<bool>();
public TargetType Target { get; } public TargetType Target { get; }
public bool ReadOnly { get; set; } public bool ReadOnly => false; //todo not yet used.
public override string ToString() => Name; public override string ToString() => Name;
[JsonProperty(@"name")] [JsonProperty(@"name")]

View File

@ -93,9 +93,11 @@ namespace osu.Game.Online.Chat
if (CurrentChannel.Value == null) if (CurrentChannel.Value == null)
return; return;
var currentChannel = CurrentChannel.Value;
if (!api.IsLoggedIn) if (!api.IsLoggedIn)
{ {
CurrentChannel.Value.AddNewMessages(new ErrorMessage("Please sign in to participate in chat!")); currentChannel.AddNewMessages(new ErrorMessage("Please sign in to participate in chat!"));
return; return;
} }
@ -109,15 +111,15 @@ namespace osu.Game.Online.Chat
Content = text Content = text
}; };
CurrentChannel.Value.AddLocalEcho(message); currentChannel.AddLocalEcho(message);
var req = new PostMessageRequest(message); var req = new PostMessageRequest(message);
req.Failure += exception => req.Failure += exception =>
{ {
Logger.Error(exception, "Posting message failed."); Logger.Error(exception, "Posting message failed.");
CurrentChannel.Value?.ReplaceMessage(message, null); currentChannel.ReplaceMessage(message, null);
}; };
req.Success += m => CurrentChannel.Value?.ReplaceMessage(message, m); req.Success += m => currentChannel.ReplaceMessage(message, m);
api.Queue(req); api.Queue(req);
} }