Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions Valour/Client/Utility/NotificationNavigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ private static (long PlanetId, long ThreadId)? TryParseThreadRoute(string clickU
return null;
}

private static readonly HashSet<NotificationSource> PlanetChannelRouteSources = new()
{
NotificationSource.PlanetMemberMention,
NotificationSource.PlanetRoleMention,
NotificationSource.PlanetMemberReply,
NotificationSource.PlanetHereMention,
NotificationSource.PlanetEveryoneMention,
NotificationSource.ChannelActivity,
};

internal static bool IsPlanetChannelRouteSource(NotificationSource source) =>
PlanetChannelRouteSources.Contains(source);

public static async Task NavigateTo(Notification notification)
{
if (notification?.Client is null)
Expand All @@ -71,11 +84,7 @@ public static async Task NavigateTo(Notification notification)
{
switch (notification.Source)
{
case NotificationSource.PlanetMemberMention:
case NotificationSource.PlanetRoleMention:
case NotificationSource.PlanetMemberReply:
case NotificationSource.PlanetHereMention:
case NotificationSource.PlanetEveryoneMention:
case var source when IsPlanetChannelRouteSource(source):
{
var planetId = notification.PlanetId;
var channelId = notification.ChannelId;
Expand Down
34 changes: 34 additions & 0 deletions Valour/Tests/Client/NotificationNavigatorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Valour.Client.Utility;
using Valour.Shared.Models;

namespace Valour.Tests.Client;

public class NotificationNavigatorTests
{
[Theory]
[InlineData(NotificationSource.ChannelActivity)]
[InlineData(NotificationSource.PlanetMemberMention)]
[InlineData(NotificationSource.PlanetRoleMention)]
[InlineData(NotificationSource.PlanetMemberReply)]
[InlineData(NotificationSource.PlanetHereMention)]
[InlineData(NotificationSource.PlanetEveryoneMention)]
public void IsPlanetChannelRouteSource_ForPlanetChannelSources_ReturnsTrue(NotificationSource source)
{
Assert.True(NotificationNavigator.IsPlanetChannelRouteSource(source));
}

[Theory]
[InlineData(NotificationSource.DirectMention)]
[InlineData(NotificationSource.DirectReply)]
[InlineData(NotificationSource.DirectMessage)]
[InlineData(NotificationSource.ThreadComment)]
[InlineData(NotificationSource.ThreadReply)]
[InlineData(NotificationSource.FriendRequest)]
[InlineData(NotificationSource.FriendRequestAccepted)]
[InlineData(NotificationSource.EventReminder)]
[InlineData(NotificationSource.Platform)]
public void IsPlanetChannelRouteSource_ForNonPlanetChannelSources_ReturnsFalse(NotificationSource source)
{
Assert.False(NotificationNavigator.IsPlanetChannelRouteSource(source));
}
}