mirror of https://github.com/ppy/osu
Reduce duplicate notification code by making a base class
This commit is contained in:
parent
cf39e58ce7
commit
a679efac1c
|
@ -142,12 +142,10 @@ private void checkForMentions(Channel channel, Message message, string username)
|
||||||
/// <returns>If the <paramref name="message"/> mentions the <paramref name="username"/></returns>
|
/// <returns>If the <paramref name="message"/> mentions the <paramref name="username"/></returns>
|
||||||
private static bool isMentioning(string message, string username) => message.IndexOf(username, StringComparison.OrdinalIgnoreCase) != -1 || message.IndexOf(username.Replace(' ', '_'), StringComparison.OrdinalIgnoreCase) != -1;
|
private static bool isMentioning(string message, string username) => message.IndexOf(username, StringComparison.OrdinalIgnoreCase) != -1 || message.IndexOf(username.Replace(' ', '_'), StringComparison.OrdinalIgnoreCase) != -1;
|
||||||
|
|
||||||
public class PrivateMessageNotification : SimpleNotification
|
public class OpenChannelNotification : SimpleNotification
|
||||||
{
|
{
|
||||||
public PrivateMessageNotification(string username, Channel channel)
|
public OpenChannelNotification(Channel channel)
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.Envelope;
|
|
||||||
Text = $"You received a private message from '{username}'. Click to read it!";
|
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,32 +169,21 @@ private void load(OsuColour colours, ChatOverlay chatOverlay, NotificationOverla
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MentionNotification : SimpleNotification
|
public class PrivateMessageNotification : OpenChannelNotification
|
||||||
{
|
{
|
||||||
public MentionNotification(string username, Channel channel)
|
public PrivateMessageNotification(string username, Channel channel) : base(channel)
|
||||||
|
{
|
||||||
|
Icon = FontAwesome.Solid.Envelope;
|
||||||
|
Text = $"You received a private message from '{username}'. Click to read it!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MentionNotification : OpenChannelNotification
|
||||||
|
{
|
||||||
|
public MentionNotification(string username, Channel channel) : base(channel)
|
||||||
{
|
{
|
||||||
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 '{username}'. Click to find out why!";
|
||||||
this.channel = channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly Channel channel;
|
|
||||||
|
|
||||||
public override bool IsImportant => false;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuColour colours, ChatOverlay chatOverlay, NotificationOverlay notificationOverlay, ChannelManager channelManager)
|
|
||||||
{
|
|
||||||
IconBackgound.Colour = colours.PurpleDark;
|
|
||||||
|
|
||||||
Activated = delegate
|
|
||||||
{
|
|
||||||
notificationOverlay.Hide();
|
|
||||||
chatOverlay.Show();
|
|
||||||
channelManager.CurrentChannel.Value = channel;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue