diff --git a/Unigram/Unigram/App.xaml.cs b/Unigram/Unigram/App.xaml.cs index 19a11ce42d..7af3a03487 100644 --- a/Unigram/Unigram/App.xaml.cs +++ b/Unigram/Unigram/App.xaml.cs @@ -45,6 +45,7 @@ using Telegram.Api.Aggregator; using Unigram.Controls; using Unigram.Views.Users; +using System.Linq; namespace Unigram { @@ -264,29 +265,36 @@ public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs if (store != null && annotationStore != null) { var full = await store.GetContactAsync(contact.Contact.Id); + if (full == null) + { + goto Navigate; + } + var annotations = await annotationStore.FindAnnotationsForContactAsync(full); + var first = annotations.FirstOrDefault(); - if (first != null) + if (first == null) { - var remote = first.RemoteId; - if (int.TryParse(remote.Substring(1), out int userId)) - { - NavigationService.Navigate(typeof(DialogPage), new TLPeerUser { UserId = userId }); - } - else - { - NavigationService.Navigate(typeof(MainPage)); - } + goto Navigate; + } + + var remote = first.RemoteId; + if (int.TryParse(remote.Substring(1), out int userId)) + { + NavigationService.Navigate(typeof(DialogPage), new TLPeerUser { UserId = userId }); } else { - NavigationService.Navigate(typeof(MainPage)); + goto Navigate; } } else { NavigationService.Navigate(typeof(MainPage)); } + + Navigate: + NavigationService.Navigate(typeof(MainPage)); } else if (args is ProtocolActivatedEventArgs protocol) {