1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 16:12:57 +08:00

Hook up message notifications to chat message highlighting logic

This commit is contained in:
Salman Ahmed 2022-03-04 23:31:32 +03:00
parent 741702549b
commit 32d242dd62

View File

@ -99,7 +99,7 @@ namespace osu.Game.Online.Chat
if (checkForPMs(channel, message)) if (checkForPMs(channel, message))
continue; continue;
checkForMentions(channel, message); checkForMentions(message);
} }
} }
@ -114,15 +114,15 @@ namespace osu.Game.Online.Chat
if (!notifyOnPrivateMessage.Value || channel.Type != ChannelType.PM) if (!notifyOnPrivateMessage.Value || channel.Type != ChannelType.PM)
return false; return false;
notifications.Post(new PrivateMessageNotification(message.Sender.Username, channel)); notifications.Post(new PrivateMessageNotification(message));
return true; return true;
} }
private void checkForMentions(Channel channel, Message message) private void checkForMentions(Message message)
{ {
if (!notifyOnUsername.Value || !CheckContainsUsername(message.Content, localUser.Value.Username)) return; if (!notifyOnUsername.Value || !CheckContainsUsername(message.Content, localUser.Value.Username)) return;
notifications.Post(new MentionNotification(message.Sender.Username, channel)); notifications.Post(new MentionNotification(message));
} }
/// <summary> /// <summary>
@ -138,32 +138,32 @@ namespace osu.Game.Online.Chat
public class PrivateMessageNotification : OpenChannelNotification public class PrivateMessageNotification : OpenChannelNotification
{ {
public PrivateMessageNotification(string username, Channel channel) public PrivateMessageNotification(Message message)
: base(channel) : base(message)
{ {
Icon = FontAwesome.Solid.Envelope; Icon = FontAwesome.Solid.Envelope;
Text = $"You received a private message from '{username}'. Click to read it!"; Text = $"You received a private message from '{message.Sender.Username}'. Click to read it!";
} }
} }
public class MentionNotification : OpenChannelNotification public class MentionNotification : OpenChannelNotification
{ {
public MentionNotification(string username, Channel channel) public MentionNotification(Message message)
: base(channel) : base(message)
{ {
Icon = FontAwesome.Solid.At; Icon = FontAwesome.Solid.At;
Text = $"Your name was mentioned in chat by '{username}'. Click to find out why!"; Text = $"Your name was mentioned in chat by '{message.Sender.Username}'. Click to find out why!";
} }
} }
public abstract class OpenChannelNotification : SimpleNotification public abstract class OpenChannelNotification : SimpleNotification
{ {
protected OpenChannelNotification(Channel channel) protected OpenChannelNotification(Message message)
{ {
this.channel = channel; this.message = message;
} }
private readonly Channel channel; private readonly Message message;
public override bool IsImportant => false; public override bool IsImportant => false;
@ -175,8 +175,8 @@ namespace osu.Game.Online.Chat
Activated = delegate Activated = delegate
{ {
notificationOverlay.Hide(); notificationOverlay.Hide();
chatOverlay.HighlightMessage(message);
chatOverlay.Show(); chatOverlay.Show();
channelManager.CurrentChannel.Value = channel;
return true; return true;
}; };