private ListPageConfig GetListPageConfig(BaseItemDto item, ViewType context)
        {
            var config = new ListPageConfig();

            if (context == ViewType.Tv)
            {
                TvViewModel.SetDefaults(config);

                if (item.IsType("season"))
                {
                    config.DefaultViewType = ListViewTypes.List;
                }
            }
            else if (context == ViewType.Movies)
            {
                MoviesViewModel.SetDefaults(config);
            }
            else if (context == ViewType.Games)
            {
                GamesViewModel.SetDefaults(config, item.GameSystem);
            }

            return(config);
        }
예제 #2
0
        private ListPageConfig GetListPageConfig(BaseItemDto item, ViewType context)
        {
            var config = new ListPageConfig();

            if (context == ViewType.Tv || item.IsType("season"))
            {
                TvViewModel.SetDefaults(config);

                if (item.IsType("season"))
                {
                    config.DefaultViewType = ListViewTypes.List;

                    config.PosterImageWidth      = 480;
                    config.PosterStripImageWidth = 592;
                    config.ThumbImageWidth       = 592;
                }
            }
            else if (context == ViewType.Movies)
            {
                MoviesViewModel.SetDefaults(config);
            }
            else if (context == ViewType.Games)
            {
                GamesViewModel.SetDefaults(config, item.GameSystem);
            }

            if (item.IsFolder)
            {
                config.CustomItemQuery = (vm, displayPreferences) =>
                {
                    if (item.IsType("series"))
                    {
                        return(_apiClient.GetSeasonsAsync(new SeasonQuery
                        {
                            UserId = _sessionManager.CurrentUser.Id,
                            SeriesId = item.Id,
                            Fields = FolderPage.QueryFields
                        }, CancellationToken.None));
                    }


                    if (item.IsType("season"))
                    {
                        return(_apiClient.GetEpisodesAsync(new EpisodeQuery
                        {
                            UserId = _sessionManager.CurrentUser.Id,
                            SeriesId = item.SeriesId,
                            SeasonId = item.Id,
                            Fields = FolderPage.QueryFields
                        }, CancellationToken.None));
                    }

                    var query = new ItemQuery
                    {
                        UserId = _sessionManager.CurrentUser.Id,

                        ParentId = item.Id,

                        Fields = FolderPage.QueryFields
                    };

                    // Server will sort boxset titles based on server settings
                    if (!item.IsType("boxset"))
                    {
                        query.SortBy    = new[] { ItemSortBy.SortName };
                        query.SortOrder = displayPreferences.SortOrder;
                    }

                    return(_apiClient.GetItemsAsync(query, CancellationToken.None));
                };

                if (item.IsType("season") && item.IndexNumber.HasValue && item.IndexNumber.Value > 0)
                {
                    config.DisplayNameGenerator = FolderPage.GetDisplayNameWithAiredSpecial;
                }
            }

            return(config);
        }