private async void Page_Loaded(object sender, RoutedEventArgs e) { try { App.Discord.MessageCreated += Notification_MessageCreated; UpdateTitleBar(); CheckSettingsPane(); _loaded = true; this.FindParent <MainPage>().HideConnectingOverlay(); var service = DiscordNavigationService.GetForCurrentView(); if (_args != null && _args.ChannelId != 0) { var channel = await App.Discord.GetChannelAsync(_args.ChannelId); await service.NavigateAsync(channel); } else { Model.IsFriendsSelected = true; SidebarFrame.Navigate(typeof(DMChannelsPage)); MainFrame.Navigate(typeof(FriendsPage)); } if (_args?.ThemeLoadException != null) { var message = App.Discord.CreateMockMessage( $"We had some trouble loading your selected themes, so we disabled them for this launch. For more information, see settings.", App.Discord.CreateMockUser("Unicord", "CORD")); ShowNotification(message); } var possibleConnection = await VoiceConnectionModel.FindExistingConnectionAsync(); if (possibleConnection != null) { (DataContext as DiscordPageModel).VoiceModel = possibleConnection; } await ContactListManager.UpdateContactsListAsync(); } catch (Exception ex) { await UIUtilities.ShowErrorDialogAsync("An error has occured.", ex.Message); } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { if (App.Discord == null) { return; // im not 100% sure why this gets called on logout but it does so } Analytics.TrackEvent("DiscordPage_Loaded"); try { App.Discord.MessageCreated += Notification_MessageCreated; UpdateTitleBar(); CheckSettingsPane(); _loaded = true; this.FindParent <MainPage>().HideConnectingOverlay(); var service = DiscordNavigationService.GetForCurrentView(); if (_args != null && _args.ChannelId != 0 && App.Discord.TryGetCachedChannel(_args.ChannelId, out var channel)) { Analytics.TrackEvent("DiscordPage_NavigateToSpecifiedChannel"); await service.NavigateAsync(channel); } else { Analytics.TrackEvent("DiscordPage_NavigateToFriendsPage"); Model.IsFriendsSelected = true; SidebarFrame.Navigate(typeof(DMChannelsPage)); MainFrame.Navigate(typeof(FriendsPage)); } if (_args?.ThemeLoadException != null) { Analytics.TrackEvent("DiscordPage_ThemeErrorMessageShown"); var message = App.Discord.CreateMockMessage( $"We had some trouble loading your selected themes, so we disabled them for this launch. For more information, see settings.", App.Discord.CreateMockUser("Unicord", "CORD")); ShowNotification(message); } //var helper = SwipeOpenService.GetForCurrentView(); //helper.AddAdditionalElement(SwipeHelper); var notificationService = BackgroundNotificationService.GetForCurrentView(); await notificationService.StartupAsync(); var possibleConnection = await VoiceConnectionModel.FindExistingConnectionAsync(); if (possibleConnection != null) { (DataContext as DiscordPageModel).VoiceModel = possibleConnection; } await ContactListManager.UpdateContactsListAsync(); } catch (Exception ex) { Logger.LogError(ex); await UIUtilities.ShowErrorDialogAsync("An error has occured.", ex.Message); } }