protected override async Task LoadData(bool isRefresh, bool add = false, int offset = 0) { if (ItemsLoaded && !isRefresh && !add) { return; } HasErrors = false; try { if (!add) { SetProgressBar("Getting notifications"); } IsLoadingMore = add; var response = await _vidMeClient.GetNotificationsAsync(offset : offset); if (response != null && !response.Notifications.IsNullOrEmpty()) { if (Items == null || !add) { Items = new ObservableCollection <NotificationItemViewModel>(); } var allNotifications = response.Notifications.Select(x => new NotificationItemViewModel(x)).ToList(); Items.AddRange(allNotifications); CanLoadMore = Items != null && Items.Count < response.Page.Total; ItemsLoaded = true; } } catch (Exception ex) { Log.ErrorException("LoadData()", ex); HasErrors = true; } SetProgressBar(); }
private async Task <int> CheckForNotificationsInternal(bool showToasts = false) { var unreadCount = 0; if (!AuthenticationService.Current.IsLoggedIn) { UpdateTileCount(0, false); return(unreadCount); } try { var response = await _vidMeClient.GetUnreadNotificationCountAsync(); unreadCount = response; if (showToasts && unreadCount > 0) { var notifications = await _vidMeClient.GetNotificationsAsync(unreadCount); if (notifications != null && !notifications.Notifications.IsNullOrEmpty()) { if (_notifications == null) { _notifications = notifications.Notifications; } } } UpdateTileCount(unreadCount, unreadCount > 0 && showToasts); } catch (Exception ex) { } return(unreadCount); }