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 SyncContactsSwitch_Toggled(object sender, RoutedEventArgs e) { syncContactsSwitch.IsEnabled = false; syncingProgressBar.Visibility = Visibility.Visible; syncingProgressBar.IsIndeterminate = true; var isEnabled = App.RoamingSettings.Read(SYNC_CONTACTS, true); if (isEnabled) { await ContactListManager.ClearContactsAsync(); } else { await ContactListManager.UpdateContactsListAsync(); } App.RoamingSettings.Save(SYNC_CONTACTS, !isEnabled); syncContactsSwitch.IsEnabled = true; syncingProgressBar.Visibility = Visibility.Collapsed; syncingProgressBar.IsIndeterminate = false; }
private async void Page_Loaded(object sender, RoutedEventArgs e) { try { var navigation = SystemNavigationManager.GetForCurrentView(); navigation.BackRequested += Navigation_BackRequested; App.Discord.MessageCreated += Notification_MessageCreated; App.Discord.UserSettingsUpdated += Discord_UserSettingsUpdated; App.Discord.GuildCreated += Discord_GuildCreated; App.Discord.GuildDeleted += Discord_GuildDeleted; App.Discord.DmChannelCreated += Discord_DmChannelCreated; App.Discord.DmChannelDeleted += Discord_DmChannelDeleted; UpdateTitleBar(); CheckSettingsPane(); _loaded = true; var guildPositions = App.Discord.UserSettings?.GuildPositions; foreach (var guild in App.Discord.Guilds.Values.OrderBy(g => guildPositions?.IndexOf(g.Id) ?? 0)) { _guilds.Add(guild); } _unreadDms.CollectionChanged += (o, ev) => { if (_unreadDms.Count > 0) { unreadDms.Visibility = Visibility.Visible; } else { unreadDms.Visibility = Visibility.Collapsed; } }; foreach (var dm in App.Discord.PrivateChannels.Values) { if (dm.ReadState.MentionCount > 0) { _unreadDms.Add(dm); } dm.PropertyChanged += Dm_PropertyChanged; } unreadDms.ItemsSource = _unreadDms; unreadDms.Visibility = _unreadDms.Count > 0 ? Visibility.Visible : Visibility.Collapsed; this.FindParent <MainPage>().HideConnectingOverlay(); //if (App.ThemeLoadException != null) //{ // await UIUtilities.ShowErrorDialogAsync("Theme failed to load!", $"Your selected theme failed to load. {App.ThemeLoadException.Message}"); //} if (_args != null) { var channel = await App.Discord.GetChannelAsync(_args.ChannelId); Navigate(channel, new DrillInNavigationTransitionInfo()); } else { friendsItem.IsSelected = true; friendsItem_Tapped(null, null); } 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); } }