mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Improve channel switching flow in HighlightMessage
This commit is contained in:
@ -435,7 +435,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("Highlight message", () => chatOverlay.HighlightMessage(message));
|
AddStep("Highlight message", () => chatOverlay.HighlightMessage(message, channel1));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -462,7 +462,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("Highlight message", () => chatOverlay.HighlightMessage(message));
|
AddStep("Highlight message", () => chatOverlay.HighlightMessage(message, channel2));
|
||||||
AddAssert("Switched to channel 2", () => channelManager.CurrentChannel.Value == channel2);
|
AddAssert("Switched to channel 2", () => channelManager.CurrentChannel.Value == channel2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,7 +491,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
});
|
});
|
||||||
AddStep("Leave channel 2", () => channelManager.LeaveChannel(channel2));
|
AddStep("Leave channel 2", () => channelManager.LeaveChannel(channel2));
|
||||||
|
|
||||||
AddStep("Highlight message", () => chatOverlay.HighlightMessage(message));
|
AddStep("Highlight message", () => chatOverlay.HighlightMessage(message, channel2));
|
||||||
AddAssert("Switched to channel 2", () => channelManager.CurrentChannel.Value == channel2);
|
AddAssert("Switched to channel 2", () => channelManager.CurrentChannel.Value == channel2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,7 +522,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
|
|
||||||
AddStep("Highlight message and show chat", () =>
|
AddStep("Highlight message and show chat", () =>
|
||||||
{
|
{
|
||||||
chatOverlay.HighlightMessage(message);
|
chatOverlay.HighlightMessage(message, channel1);
|
||||||
chatOverlay.Show();
|
chatOverlay.Show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ namespace osu.Game.Online.Chat
|
|||||||
if (checkForPMs(channel, message))
|
if (checkForPMs(channel, message))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
checkForMentions(message);
|
checkForMentions(channel, 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));
|
notifications.Post(new PrivateMessageNotification(message, channel));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForMentions(Message message)
|
private void checkForMentions(Channel channel, 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));
|
notifications.Post(new MentionNotification(message, channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -138,8 +138,8 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
public class PrivateMessageNotification : HighlightMessageNotification
|
public class PrivateMessageNotification : HighlightMessageNotification
|
||||||
{
|
{
|
||||||
public PrivateMessageNotification(Message message)
|
public PrivateMessageNotification(Message message, Channel channel)
|
||||||
: base(message)
|
: base(message, channel)
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.Envelope;
|
Icon = FontAwesome.Solid.Envelope;
|
||||||
Text = $"You received a private message from '{message.Sender.Username}'. Click to read it!";
|
Text = $"You received a private message from '{message.Sender.Username}'. Click to read it!";
|
||||||
@ -148,8 +148,8 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
public class MentionNotification : HighlightMessageNotification
|
public class MentionNotification : HighlightMessageNotification
|
||||||
{
|
{
|
||||||
public MentionNotification(Message message)
|
public MentionNotification(Message message, Channel channel)
|
||||||
: base(message)
|
: base(message, channel)
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.At;
|
Icon = FontAwesome.Solid.At;
|
||||||
Text = $"Your name was mentioned in chat by '{message.Sender.Username}'. Click to find out why!";
|
Text = $"Your name was mentioned in chat by '{message.Sender.Username}'. Click to find out why!";
|
||||||
@ -158,12 +158,14 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
public abstract class HighlightMessageNotification : SimpleNotification
|
public abstract class HighlightMessageNotification : SimpleNotification
|
||||||
{
|
{
|
||||||
protected HighlightMessageNotification(Message message)
|
protected HighlightMessageNotification(Message message, Channel channel)
|
||||||
{
|
{
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
this.channel = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Message message;
|
private readonly Message message;
|
||||||
|
private readonly Channel channel;
|
||||||
|
|
||||||
public override bool IsImportant => false;
|
public override bool IsImportant => false;
|
||||||
|
|
||||||
@ -175,7 +177,7 @@ namespace osu.Game.Online.Chat
|
|||||||
Activated = delegate
|
Activated = delegate
|
||||||
{
|
{
|
||||||
notificationOverlay.Hide();
|
notificationOverlay.Hide();
|
||||||
chatOverlay.HighlightMessage(message);
|
chatOverlay.HighlightMessage(message, channel);
|
||||||
chatOverlay.Show();
|
chatOverlay.Show();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -307,23 +308,20 @@ namespace osu.Game.Overlays
|
|||||||
/// Highlights a certain message in the specified channel.
|
/// Highlights a certain message in the specified channel.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="message">The message to highlight.</param>
|
/// <param name="message">The message to highlight.</param>
|
||||||
public void HighlightMessage(Message message)
|
/// <param name="channel">The channel containing the message.</param>
|
||||||
|
public void HighlightMessage(Message message, Channel channel)
|
||||||
{
|
{
|
||||||
Channel targetChannel;
|
Debug.Assert(channel.Id == message.ChannelId);
|
||||||
|
|
||||||
if (channelManager.CurrentChannel.Value.Id == message.ChannelId)
|
if (currentChannel.Value.Id != channel.Id)
|
||||||
targetChannel = channelManager.CurrentChannel.Value;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
targetChannel = channelManager.JoinedChannels.SingleOrDefault(c => c.Id == message.ChannelId);
|
if (!channel.Joined.Value)
|
||||||
|
channel = channelManager.JoinChannel(channel);
|
||||||
|
|
||||||
if (targetChannel != null)
|
channelManager.CurrentChannel.Value = channel;
|
||||||
channelManager.CurrentChannel.Value = targetChannel;
|
|
||||||
else
|
|
||||||
targetChannel = channelManager.JoinChannel(channelManager.AvailableChannels.SingleOrDefault(c => c.Id == message.ChannelId), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
targetChannel.HighlightedMessage.Value = message;
|
channel.HighlightedMessage.Value = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float startDragChatHeight;
|
private float startDragChatHeight;
|
||||||
|
Reference in New Issue
Block a user