Skip to content

Commit

Permalink
Incomplete fixes for contact activation
Browse files Browse the repository at this point in the history
  • Loading branch information
WamWooWam committed Sep 29, 2024
1 parent d147ec3 commit 9fcc6a4
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions Unicord.Universal/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using DSharpPlus;
using DSharpPlus.AsyncEvents;
using DSharpPlus.Entities;
Expand Down Expand Up @@ -143,6 +144,25 @@ private void OnProtocolActivatedAsync(ProtocolActivatedEventArgs protocol)
if (protocol.Uri.IsAbsoluteUri)
Analytics.TrackEvent("Unicord_LaunchForProtocol", new Dictionary<string, string>() { ["protocol"] = protocol.Uri.GetLeftPart(UriPartial.Authority) });

if (protocol.Uri.Scheme == "ms-ipmessaging")
{
var queryString = HttpUtility.ParseQueryString(protocol.Uri.Query);
var ids = queryString.GetValues("ContactRemoteIds").FirstOrDefault();
if (ids != null)
{
var id = ulong.Parse(ids.Split(',')[0].Split('_')[1]);
if (!(Window.Current.Content is Frame rootFrame))
{
rootFrame = new Frame();
Window.Current.Content = rootFrame;
}

rootFrame.Navigate(typeof(MainPage), new MainPageArgs() { UserId = id, IsUriActivation = true });
Window.Current.Activate();
return;
}
}

if (protocol.Uri.AbsolutePath.Trim('/').StartsWith("channels"))
{
var path = protocol.Uri.AbsolutePath.Split('/').Skip(1).ToArray();
Expand All @@ -154,15 +174,13 @@ private void OnProtocolActivatedAsync(ProtocolActivatedEventArgs protocol)
Window.Current.Content = rootFrame;
}

rootFrame.Navigate(typeof(MainPage), new MainPageArgs() { ChannelId = channel, FullFrame = false, IsUriActivation = true });
rootFrame.Navigate(typeof(MainPage), new MainPageArgs() { ChannelId = channel, IsUriActivation = true });
Window.Current.Activate();
return;
}
}
else
{
OnLaunched(false, "");
}

OnLaunched(false, "");
}

private static async Task OnContactPanelActivated(ContactPanelActivatedEventArgs task)
Expand Down

0 comments on commit 9fcc6a4

Please sign in to comment.