mirror of https://github.com/ppy/osu
Fix crash when the local echo is send to the wrong channel.
This commit is contained in:
parent
f681ef41ac
commit
ec914a5095
|
@ -29,7 +29,7 @@ public class Channel
|
|||
|
||||
public readonly Bindable<bool> Joined = new Bindable<bool>();
|
||||
public TargetType Target { get; }
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool ReadOnly => false; //todo not yet used.
|
||||
public override string ToString() => Name;
|
||||
|
||||
[JsonProperty(@"name")]
|
||||
|
|
|
@ -93,9 +93,11 @@ public void PostMessage(string text, bool isAction = false)
|
|||
if (CurrentChannel.Value == null)
|
||||
return;
|
||||
|
||||
var currentChannel = CurrentChannel.Value;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -109,15 +111,15 @@ public void PostMessage(string text, bool isAction = false)
|
|||
Content = text
|
||||
};
|
||||
|
||||
CurrentChannel.Value.AddLocalEcho(message);
|
||||
currentChannel.AddLocalEcho(message);
|
||||
|
||||
var req = new PostMessageRequest(message);
|
||||
req.Failure += exception =>
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue