public async Task <IAsyncEnumerable <CommunityInfoControlViewModel> > GetPagedItems(int head, int count)
        {
            CommunitySearchResponse res = head == 0 ? FirstResponse : null;

            if (res == null)
            {
                var page = (uint)((head + count) / OneTimeLoadCount);
                res = await HohoemaApp.ContentProvider.SearchCommunity(
                    SearchKeyword
                    , page
                    , Sort
                    , Order
                    , Mode
                    );
            }

            if (res == null)
            {
                return(AsyncEnumerable.Empty <CommunityInfoControlViewModel>());
            }

            if (false == res.IsStatusOK)
            {
                return(AsyncEnumerable.Empty <CommunityInfoControlViewModel>());
            }

            return(res.Communities.Select(x => new CommunityInfoControlViewModel(x, PageManager)).ToAsyncEnumerable());
        }
Example #2
0
        public async Task <IEnumerable <CommunityInfoControlViewModel> > GetPagedItems(int head, int count)
        {
            CommunitySearchResponse res = head == 0 ? FirstResponse : null;

            if (res == null)
            {
                var page = (uint)((head + count) / OneTimeLoadCount);
                res = await HohoemaApp.ContentFinder.SearchCommunity(
                    SearchKeyword
                    , page
                    , Sort
                    , Order
                    , Mode
                    );
            }

            if (res == null)
            {
                return(Enumerable.Empty <CommunityInfoControlViewModel>());
            }

            if (false == res.IsStatusOK)
            {
                return(Enumerable.Empty <CommunityInfoControlViewModel>());
            }

            var items = new List <CommunityInfoControlViewModel>();

            foreach (var commu in res.Communities)
            {
                var commuVM = new CommunityInfoControlViewModel(commu, PageManager);
                items.Add(commuVM);
            }

            return(items);
        }