private async Task <bool> GetRecentCollectionItems()
        {
            var query = Utils.GetRecentItemsQuery(SelectedFolder.Id);

            try
            {
                Log.Info("Getting recent items for collection [{0}]", SelectedFolder.Name);

                var items = await ApiClient.GetItemsAsync(query);

                if (items != null && items.Items != null)
                {
                    var recent = await Utils.SortRecentItems(items.Items, App.SpecificSettings.IncludeTrailersInRecent);

                    recent.ForEach(item => RecentItems.Add(item));
                }

                return(true);
            }
            catch (HttpException ex)
            {
                Utils.HandleHttpException(ex, "GetRecentCollectionItems()", NavigationService, Log);
                return(false);
            }
        }
Beispiel #2
0
        private async Task <bool> GetRecentItems()
        {
            try
            {
                var query = Utils.GetRecentItemsQuery(SelectedTvSeries.Id, new[] { "Season" });

                Log.Info("Getting recent items for TV Show [{0}] ({1})", SelectedTvSeries.Name, SelectedTvSeries.Id);

                var recent = await ApiClient.GetItemsAsync(query);

                if (recent != null && recent.Items != null)
                {
                    RecentItems.Clear();
                    recent.Items
                    .OrderByDescending(x => x.DateCreated)
                    .Take(6)
                    .ToList()
                    .ForEach(recentItem => RecentItems.Add(recentItem));
                }
                return(true);
            }
            catch (HttpException ex)
            {
                Utils.HandleHttpException("GetRecentItems()", ex, NavigationService, Log);

                App.ShowMessage(AppResources.ErrorRecentItems);
                return(false);
            }
        }
        private async Task SortRecent(BaseItemDto[] items)
        {
            RecentItems.Clear();

            var recent = await Utils.SortRecentItems(items, App.SpecificSettings.IncludeTrailersInRecent);

            recent.Take(6).ToList().ForEach(recentItem => RecentItems.Add(recentItem));
        }
        private async Task <bool> GetRecentItems()
        {
            try
            {
                var query = new ItemQuery
                {
                    UserId           = AuthenticationService.Current.LoggedInUser.Id,
                    ParentId         = SelectedTvSeries.Id,
                    Filters          = new[] { ItemFilter.IsRecentlyAdded },
                    ExcludeItemTypes = new [] { "Season" },
                    Fields           = new[]
                    {
                        ItemFields.ParentId
                    },
                    Recursive = true,
                    IsMissing = App.SpecificSettings.ShowMissingEpisodes,
                    IsUnaired = App.SpecificSettings.ShowUnairedEpisodes
                };

                Log.Info("Getting recent items for TV Show [{0}] ({1})", SelectedTvSeries.Name, SelectedTvSeries.Id);

                var recent = await _apiClient.GetItemsAsync(query);

                if (recent != null && recent.Items != null)
                {
                    RecentItems.Clear();
                    recent.Items
                    .OrderByDescending(x => x.DateCreated)
                    .Take(6)
                    .ToList()
                    .ForEach(recentItem => RecentItems.Add(recentItem));
                }
                return(true);
            }
            catch (HttpException ex)
            {
                Log.ErrorException("GetRecentItems()", ex);

                App.ShowMessage(AppResources.ErrorRecentItems);
                return(false);
            }
        }
Beispiel #5
0
        private async Task LoadRecentItems()
        {
            var response = await _cacheService.GetRecentItemsFromCache();

            if (RecentItems.IsNullOrEmpty())
            {
                RecentItems = new ObservableCollection <ReaderItem>(response.ReaderItems);
                return;
            }

            foreach (var item in response.ReaderItems)
            {
                var existingItem = RecentItems.FirstOrDefault(x => x.Id == item.Id);
                if (existingItem != null)
                {
                    item.CopyItem(existingItem);
                }
                else
                {
                    RecentItems.Add(item);
                }
            }
        }
Beispiel #6
0
        private async Task <bool> GetRecentCollectionItems()
        {
            var query = new ItemQuery
            {
                Filters = new[] { ItemFilter.IsRecentlyAdded, ItemFilter.IsNotFolder },
                UserId  = AuthenticationService.Current.LoggedInUser.Id,
                Fields  = new[]
                {
                    ItemFields.DateCreated,
                    ItemFields.ProviderIds,
                    ItemFields.ParentId,
                },
                ParentId  = SelectedFolder.Id,
                Recursive = true
            };

            try
            {
                Log.Info("Getting recent items for collection [{0}]", SelectedFolder.Name);

                var items = await _apiClient.GetItemsAsync(query);

                if (items != null && items.Items != null)
                {
                    var recent = await Utils.SortRecentItems(items.Items, App.SpecificSettings.IncludeTrailersInRecent);

                    recent.ForEach(item => RecentItems.Add(item));
                }

                return(true);
            }
            catch (HttpException ex)
            {
                Utils.HandleHttpException(ex, "GetRecentCollectionItems()", _navigationService, Log);
                return(false);
            }
        }