mirror of
https://github.com/ppy/osu.git
synced 2025-01-31 21:33:22 +08:00
Redo how instances of PM notifications are removed
This commit is contained in:
parent
699547e1a2
commit
5978e2c0e2
@ -122,7 +122,8 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
if (existingNotification == null)
|
if (existingNotification == null)
|
||||||
{
|
{
|
||||||
var notification = new PrivateMessageNotification(message.Sender.Username, channel);
|
var notification = new PrivateMessageNotification(message.Sender.Username, channel, (n) => privateMessageNotifications.Remove(n));
|
||||||
|
|
||||||
notificationOverlay?.Post(notification);
|
notificationOverlay?.Post(notification);
|
||||||
privateMessageNotifications.Add(notification);
|
privateMessageNotifications.Add(notification);
|
||||||
}
|
}
|
||||||
@ -154,12 +155,13 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
public class PrivateMessageNotification : SimpleNotification
|
public class PrivateMessageNotification : SimpleNotification
|
||||||
{
|
{
|
||||||
public PrivateMessageNotification(string username, Channel channel)
|
public PrivateMessageNotification(string username, Channel channel, Action<PrivateMessageNotification> onRemove)
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.Envelope;
|
Icon = FontAwesome.Solid.Envelope;
|
||||||
Username = username;
|
Username = username;
|
||||||
MessageCount = 1;
|
MessageCount = 1;
|
||||||
Channel = channel;
|
Channel = channel;
|
||||||
|
OnRemove = onRemove;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int messageCount;
|
private int messageCount;
|
||||||
@ -178,23 +180,28 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
public Channel Channel { get; set; }
|
public Channel Channel { get; set; }
|
||||||
|
|
||||||
|
public Action<PrivateMessageNotification> OnRemove { get; set; }
|
||||||
|
|
||||||
public override bool IsImportant => false;
|
public override bool IsImportant => false;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, ChatOverlay chatOverlay, NotificationOverlay notificationOverlay, ChannelManager channelManager, MessageNotifier notifier)
|
private void load(OsuColour colours, ChatOverlay chatOverlay, NotificationOverlay notificationOverlay, ChannelManager channelManager)
|
||||||
{
|
{
|
||||||
IconBackgound.Colour = colours.PurpleDark;
|
IconBackgound.Colour = colours.PurpleDark;
|
||||||
|
|
||||||
Activated = delegate
|
Activated = delegate
|
||||||
{
|
{
|
||||||
notificationOverlay.Hide();
|
notificationOverlay.Hide();
|
||||||
chatOverlay.Show();
|
chatOverlay.Show();
|
||||||
channelManager.CurrentChannel.Value = Channel;
|
channelManager.CurrentChannel.Value = Channel;
|
||||||
|
|
||||||
if (notifier.privateMessageNotifications.Contains(this))
|
|
||||||
notifier.privateMessageNotifications.Remove(this);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Closed += delegate
|
||||||
|
{
|
||||||
|
OnRemove.Invoke(this);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +222,7 @@ namespace osu.Game.Online.Chat
|
|||||||
private void load(OsuColour colours, ChatOverlay chatOverlay, NotificationOverlay notificationOverlay, ChannelManager channelManager)
|
private void load(OsuColour colours, ChatOverlay chatOverlay, NotificationOverlay notificationOverlay, ChannelManager channelManager)
|
||||||
{
|
{
|
||||||
IconBackgound.Colour = colours.PurpleDark;
|
IconBackgound.Colour = colours.PurpleDark;
|
||||||
|
|
||||||
Activated = delegate
|
Activated = delegate
|
||||||
{
|
{
|
||||||
notificationOverlay.Hide();
|
notificationOverlay.Hide();
|
||||||
|
Loading…
Reference in New Issue
Block a user